mercurial/cext/revlog.c
changeset 38847 f3d394ea17db
parent 38846 f738c502e43b
child 38848 c0d411ea6639
--- a/mercurial/cext/revlog.c	Fri Jul 20 22:26:28 2018 -0700
+++ b/mercurial/cext/revlog.c	Fri Jul 20 09:53:54 2018 -0700
@@ -158,6 +158,11 @@
 	Py_ssize_t length = index_length(self);
 	PyObject *entry;
 
+	if (pos == -1 || pos == length - 1) {
+		Py_INCREF(nullentry);
+		return nullentry;
+	}
+
 	if (pos < 0)
 		pos += length;
 
@@ -166,11 +171,6 @@
 		return NULL;
 	}
 
-	if (pos == length - 1) {
-		Py_INCREF(nullentry);
-		return nullentry;
-	}
-
 	if (pos >= self->length - 1) {
 		PyObject *obj;
 		obj = PyList_GET_ITEM(self->added, pos - self->length + 1);