##// END OF EJS Templates
sparse-revlog: add a `index_get_start` function in C...
Boris Feld -
r40739:d5b300ec default
parent child Browse files
Show More
@@ -185,6 +185,40 b' static inline int index_get_parents(inde'
185 185 return 0;
186 186 }
187 187
188 static inline int64_t index_get_start(indexObject *self, Py_ssize_t rev)
189 {
190 uint64_t offset;
191 if (rev >= self->length) {
192 PyObject *tuple;
193 PyObject *pylong;
194 PY_LONG_LONG tmp;
195 tuple = PyList_GET_ITEM(self->added, rev - self->length);
196 pylong = PyTuple_GET_ITEM(tuple, 0);
197 tmp = PyLong_AsLongLong(pylong);
198 if (tmp == -1 && PyErr_Occurred()) {
199 return -1;
200 }
201 if (tmp < 0) {
202 PyErr_Format(PyExc_OverflowError,
203 "revlog entry size out of bound (%lld)",
204 (long long)tmp);
205 return -1;
206 }
207 offset = (uint64_t)tmp;
208 } else {
209 const char *data = index_deref(self, rev);
210 offset = getbe32(data + 4);
211 if (rev == 0) {
212 /* mask out version number for the first entry */
213 offset &= 0xFFFF;
214 } else {
215 uint32_t offset_high = getbe32(data);
216 offset |= ((uint64_t)offset_high) << 32;
217 }
218 }
219 return (int64_t)(offset >> 16);
220 }
221
188 222 /*
189 223 * RevlogNG format (all in big endian, data may be inlined):
190 224 * 6 bytes: offset
General Comments 0
You need to be logged in to leave comments. Login now