Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 226:26ad7827a62d
Support status query for a single file or a subdirectory of a repository
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 25 May 2011 12:16:24 +0200 |
parents | 373e07cd3991 |
children | 1ec6b327a6ac |
comparison
equal
deleted
inserted
replaced
225:fad70a9e6c7f | 226:26ad7827a62d |
---|---|
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 | 60 |
60 | 61 |
61 public HgStatusCollector(HgRepository hgRepo) { | 62 public HgStatusCollector(HgRepository hgRepo) { |
62 this.repo = hgRepo; | 63 this.repo = hgRepo; |
63 cache = new TreeMap<Integer, ManifestRevisionInspector>(); | 64 cache = new TreeMap<Integer, ManifestRevisionInspector>(); |
216 r2 = get(rev2); | 217 r2 = get(rev2); |
217 | 218 |
218 PathPool pp = getPathPool(); | 219 PathPool pp = getPathPool(); |
219 | 220 |
220 TreeSet<String> r1Files = new TreeSet<String>(r1.files()); | 221 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 } | |
221 for (String fname : r2.files()) { | 230 for (String fname : r2.files()) { |
231 final Path r2filePath = pp.path(fname); | |
232 if (!scope.accept(r2filePath)) { | |
233 continue; | |
234 } | |
222 if (r1Files.remove(fname)) { | 235 if (r1Files.remove(fname)) { |
223 Nodeid nidR1 = r1.nodeid(fname); | 236 Nodeid nidR1 = r1.nodeid(fname); |
224 Nodeid nidR2 = r2.nodeid(fname); | 237 Nodeid nidR2 = r2.nodeid(fname); |
225 String flagsR1 = r1.flags(fname); | 238 String flagsR1 = r1.flags(fname); |
226 String flagsR2 = r2.flags(fname); | 239 String flagsR2 = r2.flags(fname); |
227 if (nidR1.equals(nidR2) && ((flagsR2 == null && flagsR1 == null) || (flagsR2 != null && flagsR2.equals(flagsR1)))) { | 240 if (nidR1.equals(nidR2) && ((flagsR2 == null && flagsR1 == null) || (flagsR2 != null && flagsR2.equals(flagsR1)))) { |
228 inspector.clean(pp.path(fname)); | 241 inspector.clean(r2filePath); |
229 } else { | 242 } else { |
230 inspector.modified(pp.path(fname)); | 243 inspector.modified(r2filePath); |
231 } | 244 } |
232 } else { | 245 } else { |
233 try { | 246 try { |
234 Path copyTarget = pp.path(fname); | 247 Path copyTarget = r2filePath; |
235 Path copyOrigin = getOriginIfCopy(repo, copyTarget, r1Files, rev1); | 248 Path copyOrigin = getOriginIfCopy(repo, copyTarget, r1Files, rev1); |
236 if (copyOrigin != null) { | 249 if (copyOrigin != null) { |
237 inspector.copied(pp.path(copyOrigin) /*pipe through pool, just in case*/, copyTarget); | 250 inspector.copied(pp.path(copyOrigin) /*pipe through pool, just in case*/, copyTarget); |
238 } else { | 251 } else { |
239 inspector.added(copyTarget); | 252 inspector.added(copyTarget); |
244 // for a single file not to be irresolvable obstacle for a status operation | 257 // for a single file not to be irresolvable obstacle for a status operation |
245 } | 258 } |
246 } | 259 } |
247 } | 260 } |
248 for (String left : r1Files) { | 261 for (String left : r1Files) { |
249 inspector.removed(pp.path(left)); | 262 final Path r2filePath = pp.path(left); |
263 if (scope.accept(r2filePath)) { | |
264 inspector.removed(r2filePath); | |
265 } | |
250 } | 266 } |
251 } | 267 } |
252 | 268 |
253 public Record status(int rev1, int rev2) { | 269 public Record status(int rev1, int rev2) { |
254 Record rv = new Record(); | 270 Record rv = new Record(); |