Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 290:8faad08c709b
Expose dirstate to allow pre-configuration of FileIterators for status collection in particular
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 14 Sep 2011 01:52:41 +0200 |
parents | ed6b74a58c66 |
children | 9774f47d904d |
comparison
equal
deleted
inserted
replaced
289:086a326f181f | 290:8faad08c709b |
---|---|
93 | 93 |
94 public void setPathPool(PathPool pathPool) { | 94 public void setPathPool(PathPool pathPool) { |
95 this.pathPool = pathPool; | 95 this.pathPool = pathPool; |
96 } | 96 } |
97 | 97 |
98 | 98 /** |
99 private HgDirstate getDirstate() { | 99 * Access to directory state information this collector uses. |
100 * @return directory state holder, never <code>null</code> | |
101 */ | |
102 public HgDirstate getDirstate() { | |
100 if (dirstate == null) { | 103 if (dirstate == null) { |
101 dirstate = repo.loadDirstate(getPathPool()); | 104 dirstate = repo.loadDirstate(getPathPool()); |
102 } | 105 } |
103 return dirstate; | 106 return dirstate; |
104 } | 107 } |
250 | 253 |
251 private void checkLocalStatusAgainstFile(Path fname, FileInfo f, HgStatusInspector inspector) { | 254 private void checkLocalStatusAgainstFile(Path fname, FileInfo f, HgStatusInspector inspector) { |
252 HgDirstate.Record r; | 255 HgDirstate.Record r; |
253 if ((r = getDirstate().checkNormal(fname)) != null) { | 256 if ((r = getDirstate().checkNormal(fname)) != null) { |
254 // either clean or modified | 257 // either clean or modified |
255 final boolean timestampEqual = f.lastModified() == r.time, sizeEqual = r.size == f.length(); | 258 final boolean timestampEqual = f.lastModified() == r.modificationTime(), sizeEqual = r.size() == f.length(); |
256 if (timestampEqual && sizeEqual) { | 259 if (timestampEqual && sizeEqual) { |
257 inspector.clean(fname); | 260 inspector.clean(fname); |
258 } else if (!sizeEqual && r.size >= 0) { | 261 } else if (!sizeEqual && r.size() >= 0) { |
259 inspector.modified(fname); | 262 inspector.modified(fname); |
260 } else { | 263 } else { |
261 // size is the same or unknown, and, perhaps, different timestamp | 264 // size is the same or unknown, and, perhaps, different timestamp |
262 // check actual content to avoid false modified files | 265 // check actual content to avoid false modified files |
263 HgDataFile df = repo.getFileNode(fname); | 266 HgDataFile df = repo.getFileNode(fname); |
267 } else { | 270 } else { |
268 inspector.clean(df.getPath()); | 271 inspector.clean(df.getPath()); |
269 } | 272 } |
270 } | 273 } |
271 } else if ((r = getDirstate().checkAdded(fname)) != null) { | 274 } else if ((r = getDirstate().checkAdded(fname)) != null) { |
272 if (r.name2 == null) { | 275 if (r.copySource() == null) { |
273 inspector.added(fname); | 276 inspector.added(fname); |
274 } else { | 277 } else { |
275 inspector.copied(getPathPool().path(r.name2), fname); | 278 inspector.copied(r.copySource(), fname); |
276 } | 279 } |
277 } else if ((r = getDirstate().checkRemoved(fname)) != null) { | 280 } else if ((r = getDirstate().checkRemoved(fname)) != null) { |
278 inspector.removed(fname); | 281 inspector.removed(fname); |
279 } else if ((r = getDirstate().checkMerged(fname)) != null) { | 282 } else if ((r = getDirstate().checkMerged(fname)) != null) { |
280 inspector.modified(fname); | 283 inspector.modified(fname); |
301 } catch (HgDataStreamException ex) { | 304 } catch (HgDataStreamException ex) { |
302 ex.printStackTrace(); | 305 ex.printStackTrace(); |
303 // FIXME report to a mediator, continue status collection | 306 // FIXME report to a mediator, continue status collection |
304 } | 307 } |
305 } else if ((r = getDirstate().checkAdded(fname)) != null) { | 308 } else if ((r = getDirstate().checkAdded(fname)) != null) { |
306 if (r.name2 != null && baseRevNames.contains(r.name2)) { | 309 if (r.copySource() != null && baseRevNames.contains(r.copySource())) { |
307 baseRevNames.remove(r.name2); // XXX surely I shall not report rename source as Removed? | 310 baseRevNames.remove(r.copySource()); // XXX surely I shall not report rename source as Removed? |
308 inspector.copied(r.name2, fname); | 311 inspector.copied(r.copySource(), fname); |
309 return; | 312 return; |
310 } | 313 } |
311 // fall-through, report as added | 314 // fall-through, report as added |
312 } else if (getDirstate().checkRemoved(fname) != null) { | 315 } else if (getDirstate().checkRemoved(fname) != null) { |
313 // removed: removed file was not known at the time of baseRevision, and we should not report it as removed | 316 // removed: removed file was not known at the time of baseRevision, and we should not report it as removed |
318 // was known; check whether clean or modified | 321 // was known; check whether clean or modified |
319 Nodeid nidFromDirstate = getDirstateParentManifest().nodeid(fname); | 322 Nodeid nidFromDirstate = getDirstateParentManifest().nodeid(fname); |
320 if ((r = getDirstate().checkNormal(fname)) != null && nid1.equals(nidFromDirstate)) { | 323 if ((r = getDirstate().checkNormal(fname)) != null && nid1.equals(nidFromDirstate)) { |
321 // regular file, was the same up to WC initialization. Check if was modified since, and, if not, report right away | 324 // regular file, was the same up to WC initialization. Check if was modified since, and, if not, report right away |
322 // same code as in #checkLocalStatusAgainstFile | 325 // same code as in #checkLocalStatusAgainstFile |
323 final boolean timestampEqual = f.lastModified() == r.time, sizeEqual = r.size == f.length(); | 326 final boolean timestampEqual = f.lastModified() == r.modificationTime(), sizeEqual = r.size() == f.length(); |
324 boolean handled = false; | 327 boolean handled = false; |
325 if (timestampEqual && sizeEqual) { | 328 if (timestampEqual && sizeEqual) { |
326 inspector.clean(fname); | 329 inspector.clean(fname); |
327 handled = true; | 330 handled = true; |
328 } else if (!sizeEqual && r.size >= 0) { | 331 } else if (!sizeEqual && r.size() >= 0) { |
329 inspector.modified(fname); | 332 inspector.modified(fname); |
330 handled = true; | 333 handled = true; |
331 } else if (!todoCheckFlagsEqual(f, flags)) { | 334 } else if (!todoCheckFlagsEqual(f, flags)) { |
332 // seems like flags have changed, no reason to check content further | 335 // seems like flags have changed, no reason to check content further |
333 inspector.modified(fname); | 336 inspector.modified(fname); |