parsers: update ntrev when we stop scanning
authorBryan O'Sullivan <bryano@fb.com>
Tue, 08 May 2012 14:46:06 -0700
changeset 16614 1d800eb9ba52
parent 16613 6a7ce975edd6
child 16615 96fa9dd1db38
parsers: update ntrev when we stop scanning This prevents us from inserting some nodes twice, wasting work.
mercurial/parsers.c
--- a/mercurial/parsers.c	Tue May 08 15:46:51 2012 -0500
+++ b/mercurial/parsers.c	Tue May 08 14:46:06 2012 -0700
@@ -690,10 +690,14 @@
 	} else {
 		for (rev = self->ntrev - 1; rev >= 0; rev--) {
 			const char *n = index_node(self, rev);
-			if (n == NULL)
+			if (n == NULL) {
+				self->ntrev = rev + 1;
 				return -2;
-			if (nt_insert(self, n, rev) == -1)
+			}
+			if (nt_insert(self, n, rev) == -1) {
+				self->ntrev = rev + 1;
 				return -3;
+			}
 			if (memcmp(node, n, nodelen > 20 ? 20 : nodelen) == 0) {
 				break;
 			}