changeset 40963:2e305e54eae3

sparse-revlog: protect C code against delta chain including nullrev For unclear reasons, some repositories include nullrev (-1). Re-computing delta for such repo remove nullrev from all chain, so some older versions have been creating them. This currently raise an IndexError with the new C code doing chain slicing as it expect all item to be positive. Both python and C code for reading delta chain preserve nullrev, and the Python code for chain slicing handle the case fine. So we take the safe route and make the new C code works fine in that case.
author Boris Feld <boris.feld@octobus.net>
date Fri, 14 Dec 2018 17:25:41 +0100
parents c6939b353ebd
children 98a0fbda8739
files mercurial/cext/revlog.c
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/revlog.c	Fri Dec 14 17:24:44 2018 +0100
+++ b/mercurial/cext/revlog.c	Fri Dec 14 17:25:41 2018 +0100
@@ -1229,7 +1229,7 @@
 		if (revnum == -1 && PyErr_Occurred()) {
 			goto bail;
 		}
-		if (revnum < 0 || revnum >= idxlen) {
+		if (revnum < nullrev || revnum >= idxlen) {
 			PyErr_Format(PyExc_IndexError,
 			             "index out of range: %zd", revnum);
 			goto bail;