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.
--- 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;