# HG changeset patch # User Boris Feld # Date 1544804741 -3600 # Node ID 2e305e54eae317f4ce98a1b0b68e78b8cacc8aa9 # Parent c6939b353ebd2b5b6fe383bd009a5315d52717c6 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. diff -r c6939b353ebd -r 2e305e54eae3 mercurial/cext/revlog.c --- 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;