Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgChangelog.java @ 154:ba2bf656f00f
Changeset => RawChangeset
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 24 Feb 2011 22:16:19 +0100 |
parents | ab7ea2ac21cb |
children | d5268ca7715b |
comparison
equal
deleted
inserted
replaced
153:ab7ea2ac21cb | 154:ba2bf656f00f |
---|---|
50 | 50 |
51 public void range(int start, int end, final HgChangelog.Inspector inspector) { | 51 public void range(int start, int end, final HgChangelog.Inspector inspector) { |
52 RevlogStream.Inspector i = new RevlogStream.Inspector() { | 52 RevlogStream.Inspector i = new RevlogStream.Inspector() { |
53 | 53 |
54 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { | 54 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { |
55 Changeset cset = Changeset.parse(data, 0, data.length); | 55 RawChangeset cset = RawChangeset.parse(data, 0, data.length); |
56 // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse | 56 // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse |
57 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); | 57 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); |
58 } | 58 } |
59 }; | 59 }; |
60 content.iterate(start, end, true, i); | 60 content.iterate(start, end, true, i); |
61 } | 61 } |
62 | 62 |
63 public List<Changeset> range(int start, int end) { | 63 public List<RawChangeset> range(int start, int end) { |
64 final ArrayList<Changeset> rv = new ArrayList<Changeset>(end - start + 1); | 64 final ArrayList<RawChangeset> rv = new ArrayList<RawChangeset>(end - start + 1); |
65 RevlogStream.Inspector i = new RevlogStream.Inspector() { | 65 RevlogStream.Inspector i = new RevlogStream.Inspector() { |
66 | 66 |
67 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { | 67 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { |
68 Changeset cset = Changeset.parse(data, 0, data.length); | 68 RawChangeset cset = RawChangeset.parse(data, 0, data.length); |
69 rv.add(cset); | 69 rv.add(cset); |
70 } | 70 } |
71 }; | 71 }; |
72 content.iterate(start, end, true, i); | 72 content.iterate(start, end, true, i); |
73 return rv; | 73 return rv; |
79 } | 79 } |
80 RevlogStream.Inspector i = new RevlogStream.Inspector() { | 80 RevlogStream.Inspector i = new RevlogStream.Inspector() { |
81 | 81 |
82 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { | 82 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { |
83 if (Arrays.binarySearch(revisions, revisionNumber) >= 0) { | 83 if (Arrays.binarySearch(revisions, revisionNumber) >= 0) { |
84 Changeset cset = Changeset.parse(data, 0, data.length); | 84 RawChangeset cset = RawChangeset.parse(data, 0, data.length); |
85 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); | 85 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); |
86 } | 86 } |
87 } | 87 } |
88 }; | 88 }; |
89 Arrays.sort(revisions); | 89 Arrays.sort(revisions); |
90 content.iterate(revisions[0], revisions[revisions.length - 1], true, i); | 90 content.iterate(revisions[0], revisions[revisions.length - 1], true, i); |
91 } | 91 } |
92 | 92 |
93 public interface Inspector { | 93 public interface Inspector { |
94 // TODO describe whether cset is new instance each time | 94 // TODO describe whether cset is new instance each time |
95 void next(int revisionNumber, Nodeid nodeid, Changeset cset); | 95 void next(int revisionNumber, Nodeid nodeid, RawChangeset cset); |
96 } | 96 } |
97 | 97 |
98 /** | 98 /** |
99 * Entry in the Changelog | 99 * Entry in the Changelog |
100 */ | 100 */ |
101 public static class Changeset implements Cloneable /* for those that would like to keep a copy */{ | 101 public static class RawChangeset implements Cloneable /* for those that would like to keep a copy */{ |
102 // TODO immutable | 102 // TODO immutable |
103 private/* final */Nodeid manifest; | 103 private/* final */Nodeid manifest; |
104 private String user; | 104 private String user; |
105 private String comment; | 105 private String comment; |
106 private List<String> files; // unmodifiable collection (otherwise #files() and implicit #clone() shall be revised) | 106 private List<String> files; // unmodifiable collection (otherwise #files() and implicit #clone() shall be revised) |
122 * (.*) : comment (free text, ideally utf-8) | 122 * (.*) : comment (free text, ideally utf-8) |
123 * | 123 * |
124 * changelog v0 doesn't use extra | 124 * changelog v0 doesn't use extra |
125 * </pre> | 125 * </pre> |
126 */ | 126 */ |
127 private Changeset() { | 127 private RawChangeset() { |
128 } | 128 } |
129 | 129 |
130 public Nodeid manifest() { | 130 public Nodeid manifest() { |
131 return manifest; | 131 return manifest; |
132 } | 132 } |
188 sb.append("}"); | 188 sb.append("}"); |
189 return sb.toString(); | 189 return sb.toString(); |
190 } | 190 } |
191 | 191 |
192 @Override | 192 @Override |
193 public Changeset clone() { | 193 public RawChangeset clone() { |
194 try { | 194 try { |
195 return (Changeset) super.clone(); | 195 return (RawChangeset) super.clone(); |
196 } catch (CloneNotSupportedException ex) { | 196 } catch (CloneNotSupportedException ex) { |
197 throw new InternalError(ex.toString()); | 197 throw new InternalError(ex.toString()); |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 public static Changeset parse(byte[] data, int offset, int length) { | 201 public static RawChangeset parse(byte[] data, int offset, int length) { |
202 Changeset rv = new Changeset(); | 202 RawChangeset rv = new RawChangeset(); |
203 rv.init(data, offset, length); | 203 rv.init(data, offset, length); |
204 return rv; | 204 return rv; |
205 } | 205 } |
206 | 206 |
207 /* package-local */void init(byte[] data, int offset, int length) { | 207 /* package-local */void init(byte[] data, int offset, int length) { |