diff src/com/tmate/hgkit/ll/WorkingCopyStatusCollector.java @ 68:0e499fed9b3d

StatusCommand with tests. Extra constants to indicate common revision cases
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 22 Jan 2011 22:11:24 +0100
parents a47530a2ea12
children
line wrap: on
line diff
--- a/src/com/tmate/hgkit/ll/WorkingCopyStatusCollector.java	Fri Jan 21 19:21:43 2011 +0100
+++ b/src/com/tmate/hgkit/ll/WorkingCopyStatusCollector.java	Sat Jan 22 22:11:24 2011 +0100
@@ -3,6 +3,7 @@
  */
 package com.tmate.hgkit.ll;
 
+import static com.tmate.hgkit.ll.HgRepository.BAD_REVISION;
 import static com.tmate.hgkit.ll.HgRepository.TIP;
 
 import java.io.BufferedInputStream;
@@ -54,7 +55,13 @@
 	public void walk(int baseRevision, StatusCollector.Inspector inspector) {
 		final HgIgnore hgIgnore = ((LocalHgRepo) repo).loadIgnore(); // FIXME hack
 		TreeSet<String> knownEntries = getDirstate().all();
-		final boolean isTipBase = baseRevision == TIP || baseRevision == repo.getManifest().getRevisionCount();
+		final boolean isTipBase;
+		if (baseRevision == TIP) {
+			baseRevision = repo.getManifest().getRevisionCount() - 1;
+			isTipBase = true;
+		} else {
+			isTipBase = baseRevision == repo.getManifest().getRevisionCount() - 1;
+		}
 		StatusCollector.ManifestRevisionInspector collect = null;
 		Set<String> baseRevFiles = Collections.emptySet();
 		if (!isTipBase) {
@@ -66,6 +73,10 @@
 			}
 			baseRevFiles = new TreeSet<String>(collect.files(baseRevision));
 		}
+		if (inspector instanceof StatusCollector.Record) {
+			StatusCollector sc = baseRevisionCollector == null ? new StatusCollector(repo) : baseRevisionCollector;
+			((StatusCollector.Record) inspector).init(baseRevision, BAD_REVISION, sc);
+		}
 		repoWalker.reset();
 		while (repoWalker.hasNext()) {
 			repoWalker.next();