# HG changeset patch
# User Artem Tikhomirov <tikhomirov.artem@gmail.com>
# Date 1317098094 -7200
# Node ID fb74133d20253f4af5512e0eed58c04edbe4841c
# Parent  c1e3c18fd2f2041a221e9be9f8354c103fd99d6c
Issue 14: NPE for merged dirstate and a file missed in dirstate's first parent

diff -r c1e3c18fd2f2 -r fb74133d2025 src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java
--- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Tue Sep 27 05:57:30 2011 +0200
+++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java	Tue Sep 27 06:34:54 2011 +0200
@@ -272,7 +272,11 @@
 				// check actual content to avoid false modified files
 				HgDataFile df = repo.getFileNode(fname);
 				Nodeid rev = getDirstateParentManifest().nodeid(fname);
-				if (!areTheSame(f, df, rev)) {
+				// 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.
+				// E.g. fork revision 3, revision 4 gets .hgtags, few modifications and merge(3,12)
+				// see Issue 14 for details
+				if (rev == null || !areTheSame(f, df, rev)) {
 					inspector.modified(df.getPath());
 				} else {
 					inspector.clean(df.getPath());