Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 229:1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Tue, 31 May 2011 05:23:07 +0200 |
| parents | 26ad7827a62d |
| children | 3fbfce107f94 |
comparison
equal
deleted
inserted
replaced
| 228:fffe4f882248 | 229:1ec6b327a6ac |
|---|---|
| 54 private final int cacheMaxSize = 50; // do not keep too much manifest revisions | 54 private final int cacheMaxSize = 50; // do not keep too much manifest revisions |
| 55 private PathPool pathPool; | 55 private PathPool pathPool; |
| 56 private final Pool<Nodeid> cacheNodes; | 56 private final Pool<Nodeid> cacheNodes; |
| 57 private final Pool<String> cacheFilenames; // XXX in fact, need to think if use of PathPool directly instead is better solution | 57 private final Pool<String> cacheFilenames; // XXX in fact, need to think if use of PathPool directly instead is better solution |
| 58 private final ManifestRevisionInspector emptyFakeState; | 58 private final ManifestRevisionInspector emptyFakeState; |
| 59 private Path.Matcher scope; | 59 private Path.Matcher scope = new Path.Matcher.Any(); |
| 60 | 60 |
| 61 | 61 |
| 62 public HgStatusCollector(HgRepository hgRepo) { | 62 public HgStatusCollector(HgRepository hgRepo) { |
| 63 this.repo = hgRepo; | 63 this.repo = hgRepo; |
| 64 cache = new TreeMap<Integer, ManifestRevisionInspector>(); | 64 cache = new TreeMap<Integer, ManifestRevisionInspector>(); |
| 150 * Allows sharing of a common path cache | 150 * Allows sharing of a common path cache |
| 151 */ | 151 */ |
| 152 public void setPathPool(PathPool pathPool) { | 152 public void setPathPool(PathPool pathPool) { |
| 153 this.pathPool = pathPool; | 153 this.pathPool = pathPool; |
| 154 } | 154 } |
| 155 | 155 |
| 156 /** | |
| 157 * Limit activity of the collector to certain sub-tree of the repository. | |
| 158 * @param scopeMatcher tells whether collector shall report specific path, can be <code>null</code> | |
| 159 */ | |
| 160 public void setScope(Path.Matcher scopeMatcher) { | |
| 161 // do not assign null, ever | |
| 162 scope = scopeMatcher == null ? new Path.Matcher.Any() : scopeMatcher; | |
| 163 } | |
| 156 | 164 |
| 157 // hg status --change <rev> | 165 // hg status --change <rev> |
| 158 public void change(int rev, HgStatusInspector inspector) { | 166 public void change(int rev, HgStatusInspector inspector) { |
| 159 int[] parents = new int[2]; | 167 int[] parents = new int[2]; |
| 160 repo.getChangelog().parents(rev, parents, null, null); | 168 repo.getChangelog().parents(rev, parents, null, null); |
| 215 } | 223 } |
| 216 r1 = get(rev1); | 224 r1 = get(rev1); |
| 217 r2 = get(rev2); | 225 r2 = get(rev2); |
| 218 | 226 |
| 219 PathPool pp = getPathPool(); | 227 PathPool pp = getPathPool(); |
| 220 | |
| 221 TreeSet<String> r1Files = new TreeSet<String>(r1.files()); | 228 TreeSet<String> r1Files = new TreeSet<String>(r1.files()); |
| 222 class MatchAny implements Path.Matcher { | |
| 223 public boolean accept(Path path) { | |
| 224 return true; | |
| 225 } | |
| 226 }; | |
| 227 if (scope == null) { | |
| 228 scope = new MatchAny(); // FIXME configure from outside | |
| 229 } | |
| 230 for (String fname : r2.files()) { | 229 for (String fname : r2.files()) { |
| 231 final Path r2filePath = pp.path(fname); | 230 final Path r2filePath = pp.path(fname); |
| 232 if (!scope.accept(r2filePath)) { | 231 if (!scope.accept(r2filePath)) { |
| 233 continue; | 232 continue; |
| 234 } | 233 } |
