Mercurial > jhg
comparison src/com/tmate/hgkit/ll/StatusCollector.java @ 56:576d6e8a09f6
Analog of 'hg status --change' command
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 17 Jan 2011 05:15:13 +0100 |
parents | 05829a70b30b |
children | b771e94a4f7c |
comparison
equal
deleted
inserted
replaced
55:05829a70b30b | 56:576d6e8a09f6 |
---|---|
22 private final Map<Integer, ManifestRevisionInspector> cache; // sparse array, in fact | 22 private final Map<Integer, ManifestRevisionInspector> cache; // sparse array, in fact |
23 | 23 |
24 public StatusCollector(HgRepository hgRepo) { | 24 public StatusCollector(HgRepository hgRepo) { |
25 this.repo = hgRepo; | 25 this.repo = hgRepo; |
26 cache = new HashMap<Integer, ManifestRevisionInspector>(); | 26 cache = new HashMap<Integer, ManifestRevisionInspector>(); |
27 ManifestRevisionInspector emptyFakeState = new ManifestRevisionInspector(-1, -1); | |
28 emptyFakeState.begin(-1, null); | |
29 emptyFakeState.end(-1); | |
30 cache.put(-1, emptyFakeState); | |
27 } | 31 } |
28 | 32 |
29 private ManifestRevisionInspector get(int rev) { | 33 private ManifestRevisionInspector get(int rev) { |
30 ManifestRevisionInspector i = cache.get(rev); | 34 ManifestRevisionInspector i = cache.get(rev); |
31 if (i == null) { | 35 if (i == null) { |
33 cache.put(rev, i); | 37 cache.put(rev, i); |
34 repo.getManifest().walk(rev, rev, i); | 38 repo.getManifest().walk(rev, rev, i); |
35 } | 39 } |
36 return i; | 40 return i; |
37 } | 41 } |
38 | 42 |
43 // hg status --change <rev> | |
44 public void change(int rev, Inspector inspector) { | |
45 int[] parents = new int[2]; | |
46 repo.getChangelog().parents(rev, parents, null, null); | |
47 walk(parents[0], rev, inspector); | |
48 } | |
49 | |
50 // I assume revision numbers are the same for changelog and manifest - here | |
51 // user would like to pass changelog revision numbers, and I use them directly to walk manifest. | |
52 // if this assumption is wrong, fix this (lookup manifest revisions from changeset). | |
39 public void walk(int rev1, int rev2, Inspector inspector) { | 53 public void walk(int rev1, int rev2, Inspector inspector) { |
40 if (rev1 == rev2) { | 54 if (rev1 == rev2) { |
41 throw new IllegalArgumentException(); | 55 throw new IllegalArgumentException(); |
42 } | 56 } |
43 // in fact, rev1 and rev2 are often next (or close) to each other, | 57 // in fact, rev1 and rev2 are often next (or close) to each other, |
196 private final int baseRevision; | 210 private final int baseRevision; |
197 private int r = -1; // cursor | 211 private int r = -1; // cursor |
198 | 212 |
199 /** | 213 /** |
200 * [minRev, maxRev] | 214 * [minRev, maxRev] |
215 * [-1,-1] also accepted (for fake empty instance) | |
201 * @param minRev - inclusive | 216 * @param minRev - inclusive |
202 * @param maxRev - inclusive | 217 * @param maxRev - inclusive |
203 */ | 218 */ |
204 @SuppressWarnings("unchecked") | 219 @SuppressWarnings("unchecked") |
205 public ManifestRevisionInspector(int minRev, int maxRev) { | 220 public ManifestRevisionInspector(int minRev, int maxRev) { |