diff src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 293:9774f47d904d

Issue 13: Status reports filenames with case other than in dirstate incorrectly
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 14 Sep 2011 04:11:37 +0200
parents 8faad08c709b
children 32890bab7209
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Wed Sep 14 02:16:19 2011 +0200
+++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Wed Sep 14 04:11:37 2011 +0200
@@ -161,16 +161,21 @@
 			((HgStatusCollector.Record) inspector).init(rev1, rev2, sc);
 		}
 		final HgIgnore hgIgnore = repo.getIgnore();
-		TreeSet<Path> knownEntries = getDirstate().all();
 		repoWalker.reset();
+		TreeSet<Path> processed = new TreeSet<Path>(); // names of files we handled as they known to Dirstate (not FileIterator)
+		final HgDirstate ds = getDirstate();
+		TreeSet<Path> knownEntries = ds.all(); // here just to get dirstate initialized
 		while (repoWalker.hasNext()) {
 			repoWalker.next();
 			final Path fname = getPathPool().path(repoWalker.name());
 			FileInfo f = repoWalker.file();
+			Path knownInDirstate;
 			if (!f.exists()) {
 				// file coming from iterator doesn't exist.
-				if (knownEntries.remove(fname)) {
-					if (getDirstate().checkRemoved(fname) == null) {
+				if ((knownInDirstate = ds.known(fname)) != null) {
+					// found in dirstate
+					processed.add(knownInDirstate);
+					if (ds.checkRemoved(fname) == null) {
 						inspector.missing(fname);
 					} else {
 						inspector.removed(fname);
@@ -197,9 +202,10 @@
 				}
 				continue;
 			}
-			if (knownEntries.remove(fname)) {
+			if ((knownInDirstate = ds.known(fname)) != null) {
 				// tracked file.
 				// modified, added, removed, clean
+				processed.add(knownInDirstate);
 				if (collect != null) { // need to check against base revision, not FS file
 					checkLocalStatusAgainstBaseRevision(baseRevFiles, collect, baseRevision, fname, f, inspector);
 				} else {
@@ -223,13 +229,14 @@
 				}
 			}
 		}
+		knownEntries.removeAll(processed);
 		for (Path m : knownEntries) {
 			if (!repoWalker.inScope(m)) {
 				// do not report as missing/removed those FileIterator doesn't care about.
 				continue;
 			}
 			// missing known file from a working dir  
-			if (getDirstate().checkRemoved(m) == null) {
+			if (ds.checkRemoved(m) == null) {
 				// not removed from the repository = 'deleted'  
 				inspector.missing(m);
 			} else {