changeset 337:f377f833b780

Issue 17: temporary code to nail down the problem
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 15 Nov 2011 03:07:28 +0100
parents f74e36b7344b
children 3cfa4d908fc9
files src/org/tmatesoft/hg/repo/HgRepository.java src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgRepository.java	Fri Nov 11 05:56:09 2011 +0100
+++ b/src/org/tmatesoft/hg/repo/HgRepository.java	Tue Nov 15 03:07:28 2011 +0100
@@ -303,6 +303,11 @@
 	/*package-local*/ File getRepositoryRoot() {
 		return repoDir;
 	}
+	
+	// FIXME remove once NPE in HgWorkingCopyStatusCollector.areTheSame is solved
+	/*package-local, debug*/String getStoragePath(HgDataFile df) {
+		return dataPathHelper.rewrite(df.getPath().toString()).toString();
+	}
 
 	// XXX package-local, unless there are cases when required from outside (guess, working dir/revision walkers may hide dirstate access and no public visibility needed)
 	// XXX consider passing Path pool or factory to produce (shared) Path instead of Strings
--- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Fri Nov 11 05:56:09 2011 +0100
+++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Tue Nov 15 03:07:28 2011 +0100
@@ -30,6 +30,7 @@
 import java.util.Set;
 import java.util.TreeSet;
 
+import org.tmatesoft.hg.core.HgBadStateException;
 import org.tmatesoft.hg.core.HgDataStreamException;
 import org.tmatesoft.hg.core.HgException;
 import org.tmatesoft.hg.core.Nodeid;
@@ -271,6 +272,10 @@
 				// size is the same or unknown, and, perhaps, different timestamp
 				// check actual content to avoid false modified files
 				HgDataFile df = repo.getFileNode(fname);
+				if (!df.exists()) {
+					String msg = String.format("File %s known as normal in dirstate (%d, %d), doesn't exist at %s", fname, r.modificationTime(), r.size(), repo.getStoragePath(df));
+					throw new HgBadStateException(msg);
+				}
 				Nodeid rev = getDirstateParentManifest().nodeid(fname);
 				// rev might be null here if fname comes to dirstate as a result of a merge operation
 				// where one of the parents (first parent) had no fname file, but second parent had.