Mercurial > hg
comparison mercurial/cext/revlog.c @ 38852:a3dacabd476b
index: don't allow index[len(index)] to mean nullid
Now everything else has been cleaned up and we can drop support for
getting the nullid from the end of the index (from *past* the end
actually, since we reduced the length in the previous patch).
Differential Revision: https://phab.mercurial-scm.org/D4023
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 20 Jul 2018 14:36:42 -0700 |
parents | 781b2720d2ac |
children | aa33988ad8ab |
comparison
equal
deleted
inserted
replaced
38851:781b2720d2ac | 38852:a3dacabd476b |
---|---|
156 const char *c_node_id; | 156 const char *c_node_id; |
157 const char *data; | 157 const char *data; |
158 Py_ssize_t length = index_length(self) + 1; | 158 Py_ssize_t length = index_length(self) + 1; |
159 PyObject *entry; | 159 PyObject *entry; |
160 | 160 |
161 if (pos == -1 || pos == length - 1) { | 161 if (pos == -1) { |
162 Py_INCREF(nullentry); | 162 Py_INCREF(nullentry); |
163 return nullentry; | 163 return nullentry; |
164 } | 164 } |
165 | 165 |
166 if (pos < 0 || pos >= length) { | 166 if (pos < 0 || pos >= length - 1) { |
167 PyErr_SetString(PyExc_IndexError, "revlog index out of range"); | 167 PyErr_SetString(PyExc_IndexError, "revlog index out of range"); |
168 return NULL; | 168 return NULL; |
169 } | 169 } |
170 | 170 |
171 if (pos >= self->length - 1) { | 171 if (pos >= self->length - 1) { |