Mercurial > hg4j
comparison src/com/tmate/hgkit/ll/Changeset.java @ 49:26e3eeaa3962
branch and user filtering for log operation
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 15 Jan 2011 01:15:38 +0100 |
parents | b01500fe2604 |
children | fd4f2c98995b |
comparison
equal
deleted
inserted
replaced
48:e34f90b9ded1 | 49:26e3eeaa3962 |
---|---|
6 import java.io.UnsupportedEncodingException; | 6 import java.io.UnsupportedEncodingException; |
7 import java.util.ArrayList; | 7 import java.util.ArrayList; |
8 import java.util.Collections; | 8 import java.util.Collections; |
9 import java.util.Date; | 9 import java.util.Date; |
10 import java.util.Formatter; | 10 import java.util.Formatter; |
11 import java.util.HashMap; | |
11 import java.util.List; | 12 import java.util.List; |
12 import java.util.Locale; | 13 import java.util.Locale; |
13 import java.util.Map; | 14 import java.util.Map; |
14 | 15 |
15 /** | 16 /** |
34 private String user; | 35 private String user; |
35 private String comment; | 36 private String comment; |
36 private List<String> files; // unmodifiable collection (otherwise #files() and implicit #clone() shall be revised) | 37 private List<String> files; // unmodifiable collection (otherwise #files() and implicit #clone() shall be revised) |
37 private Date time; | 38 private Date time; |
38 private int timezone; // not sure it's of any use | 39 private int timezone; // not sure it's of any use |
39 private String extras; // TODO branch, etc. | 40 private Map<String,String> extras; |
40 | 41 |
41 private Changeset() { | 42 private Changeset() { |
42 } | 43 } |
43 | 44 |
44 public Nodeid manifest() { | 45 public Nodeid manifest() { |
67 f.format("%ta %<tb %<td %<tH:%<tM:%<tS %<tY %<tz", time); | 68 f.format("%ta %<tb %<td %<tH:%<tM:%<tS %<tY %<tz", time); |
68 return sb.toString(); | 69 return sb.toString(); |
69 } | 70 } |
70 | 71 |
71 public Map<String, String> extras() { | 72 public Map<String, String> extras() { |
72 return null; // TODO | 73 return extras; |
74 } | |
75 | |
76 public String branch() { | |
77 return extras.get("branch"); | |
73 } | 78 } |
74 | 79 |
75 @Override | 80 @Override |
76 public String toString() { | 81 public String toString() { |
77 StringBuilder sb = new StringBuilder(); | 82 StringBuilder sb = new StringBuilder(); |
127 int _timezone = Integer.parseInt(_timeString.substring(space1+1, space2)); | 132 int _timezone = Integer.parseInt(_timeString.substring(space1+1, space2)); |
128 // XXX not sure need to add timezone here - I can't figure out whether Hg keeps GMT time, and records timezone just for info, or unixTime is taken local | 133 // XXX not sure need to add timezone here - I can't figure out whether Hg keeps GMT time, and records timezone just for info, or unixTime is taken local |
129 // on commit and timezone is recorded to adjust it to UTC. | 134 // on commit and timezone is recorded to adjust it to UTC. |
130 Date _time = new Date(unixTime * 1000); | 135 Date _time = new Date(unixTime * 1000); |
131 String _extras = space2 < _timeString.length() ? _timeString.substring(space2+1) : null; | 136 String _extras = space2 < _timeString.length() ? _timeString.substring(space2+1) : null; |
137 Map<String, String> _extrasMap; | |
138 if (_extras == null) { | |
139 _extrasMap = Collections.singletonMap("branch", "default"); | |
140 } else { | |
141 _extrasMap = new HashMap<String, String>(); | |
142 for (String pair : _extras.split("\00")) { | |
143 int eq = pair.indexOf('='); | |
144 // FIXME need to decode key/value, @see changelog.py:decodeextra | |
145 _extrasMap.put(pair.substring(0, eq), pair.substring(eq+1)); | |
146 } | |
147 if (!_extrasMap.containsKey("branch")) { | |
148 _extrasMap.put("branch", "default"); | |
149 } | |
150 _extrasMap = Collections.unmodifiableMap(_extrasMap); | |
151 } | |
132 | 152 |
133 // | 153 // |
134 int lastStart = breakIndex3 + 1; | 154 int lastStart = breakIndex3 + 1; |
135 int breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); | 155 int breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); |
136 ArrayList<String> _files = new ArrayList<String>(5); | 156 ArrayList<String> _files = new ArrayList<String>(5); |
159 this.user = _user; | 179 this.user = _user; |
160 this.time = _time; | 180 this.time = _time; |
161 this.timezone = _timezone; | 181 this.timezone = _timezone; |
162 this.files = Collections.unmodifiableList(_files); | 182 this.files = Collections.unmodifiableList(_files); |
163 this.comment = _comment; | 183 this.comment = _comment; |
164 this.extras = _extras; | 184 this.extras = _extrasMap; |
165 } | 185 } |
166 | 186 |
167 private static int indexOf(byte[] src, byte what, int startOffset, int endIndex) { | 187 private static int indexOf(byte[] src, byte what, int startOffset, int endIndex) { |
168 for (int i = startOffset; i < endIndex; i++) { | 188 for (int i = startOffset; i < endIndex; i++) { |
169 if (src[i] == what) { | 189 if (src[i] == what) { |