parsers: reduce raw_length when truncating
authorBryan O'Sullivan <bryano@fb.com>
Sat, 19 May 2012 19:44:18 -0700
changeset 16784 12a852c7c763
parent 16783 bb446969efd4
child 16785 1dc08dc63c09
parsers: reduce raw_length when truncating When stripping revs, we now update raw_length to correctly reflect the new end of the index.
mercurial/parsers.c
--- a/mercurial/parsers.c	Tue May 22 22:08:41 2012 +0200
+++ b/mercurial/parsers.c	Sat May 19 19:44:18 2012 -0700
@@ -930,6 +930,7 @@
 {
 	Py_ssize_t start, stop, step, slicelength;
 	Py_ssize_t length = index_length(self);
+	int ret = 0;
 
 	if (PySlice_GetIndicesEx((PySliceObject*)item, length,
 				 &start, &stop, &step, &slicelength) < 0)
@@ -975,7 +976,9 @@
 				self->ntrev = (int)start;
 		}
 		self->length = start + 1;
-		return 0;
+		if (start < self->raw_length)
+			self->raw_length = start;
+		goto done;
 	}
 
 	if (self->nt) {
@@ -983,10 +986,11 @@
 		if (self->ntrev > start)
 			self->ntrev = (int)start;
 	}
-	return self->added
-		? PyList_SetSlice(self->added, start - self->length + 1,
-				  PyList_GET_SIZE(self->added), NULL)
-		: 0;
+	if (self->added)
+		ret = PyList_SetSlice(self->added, start - self->length + 1,
+				      PyList_GET_SIZE(self->added), NULL);
+done:
+	return ret;
 }
 
 /*