diff -r 781b2720d2ac -r a3dacabd476b mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c Fri Jul 20 08:10:32 2018 -0700 +++ b/mercurial/cext/revlog.c Fri Jul 20 14:36:42 2018 -0700 @@ -158,12 +158,12 @@ Py_ssize_t length = index_length(self) + 1; PyObject *entry; - if (pos == -1 || pos == length - 1) { + if (pos == -1) { Py_INCREF(nullentry); return nullentry; } - if (pos < 0 || pos >= length) { + if (pos < 0 || pos >= length - 1) { PyErr_SetString(PyExc_IndexError, "revlog index out of range"); return NULL; }