[PATCH 1 of 4] parsers: reduce raw_length when truncating

Bryan O'Sullivan bos at serpentine.com
Sat May 19 22:21:52 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1337481858 25200
# Node ID 734e96ba67195579189ae2d119365a74f1f33cc4
# Parent  9acb5cd19162bdb1053429df9ce9a13c2d15aea8
parsers: reduce raw_length when truncating

When stripping revs, we now update raw_length to correctly reflect
the new end of the index.

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -930,6 +930,7 @@ static int index_slice_del(indexObject *
 {
 	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 @@ static int index_slice_del(indexObject *
 				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 @@ static int index_slice_del(indexObject *
 		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;
 }
 
 /*


More information about the Mercurial-devel mailing list