Show More
@@ -713,7 +713,7 b' void dirs_module_init(PyObject *mod);' | |||
|
713 | 713 | void manifest_module_init(PyObject *mod); |
|
714 | 714 | void revlog_module_init(PyObject *mod); |
|
715 | 715 | |
|
716 |
static const int version = |
|
|
716 | static const int version = 7; | |
|
717 | 717 | |
|
718 | 718 | static void module_init(PyObject *mod) |
|
719 | 719 | { |
@@ -77,8 +77,8 b' typedef struct {' | |||
|
77 | 77 | static Py_ssize_t index_length(const indexObject *self) |
|
78 | 78 | { |
|
79 | 79 | if (self->added == NULL) |
|
80 | return self->length; | |
|
81 | return self->length + PyList_GET_SIZE(self->added); | |
|
80 | return self->length - 1; | |
|
81 | return self->length + PyList_GET_SIZE(self->added) - 1; | |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | 84 | static PyObject *nullentry; |
@@ -155,7 +155,7 b' static PyObject *index_get(indexObject *' | |||
|
155 | 155 | int comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2; |
|
156 | 156 | const char *c_node_id; |
|
157 | 157 | const char *data; |
|
158 | Py_ssize_t length = index_length(self); | |
|
158 | Py_ssize_t length = index_length(self) + 1; | |
|
159 | 159 | PyObject *entry; |
|
160 | 160 | |
|
161 | 161 | if (pos == -1 || pos == length - 1) { |
@@ -225,7 +225,7 b' static PyObject *index_get(indexObject *' | |||
|
225 | 225 | */ |
|
226 | 226 | static const char *index_node(indexObject *self, Py_ssize_t pos) |
|
227 | 227 | { |
|
228 | Py_ssize_t length = index_length(self); | |
|
228 | Py_ssize_t length = index_length(self) + 1; | |
|
229 | 229 | const char *data; |
|
230 | 230 | |
|
231 | 231 | if (pos == length - 1 || pos == -1) |
@@ -285,7 +285,7 b' static PyObject *index_append(indexObjec' | |||
|
285 | 285 | if (node_check(PyTuple_GET_ITEM(obj, 7), &node) == -1) |
|
286 | 286 | return NULL; |
|
287 | 287 | |
|
288 | len = index_length(self); | |
|
288 | len = index_length(self) + 1; | |
|
289 | 289 | |
|
290 | 290 | if (self->added == NULL) { |
|
291 | 291 | self->added = PyList_New(0); |
@@ -435,7 +435,7 b' static Py_ssize_t add_roots_get_min(inde' | |||
|
435 | 435 | { |
|
436 | 436 | PyObject *iter = NULL; |
|
437 | 437 | PyObject *iter_item = NULL; |
|
438 |
Py_ssize_t min_idx = index_length(self) + |
|
|
438 | Py_ssize_t min_idx = index_length(self) + 2; | |
|
439 | 439 | long iter_item_long; |
|
440 | 440 | |
|
441 | 441 | if (PyList_GET_SIZE(list) != 0) { |
@@ -477,7 +477,7 b' static PyObject *reachableroots2(indexOb' | |||
|
477 | 477 | PyObject *reachable = NULL; |
|
478 | 478 | |
|
479 | 479 | PyObject *val; |
|
480 |
Py_ssize_t len = index_length(self) |
|
|
480 | Py_ssize_t len = index_length(self); | |
|
481 | 481 | long revnum; |
|
482 | 482 | Py_ssize_t k; |
|
483 | 483 | Py_ssize_t i; |
@@ -629,7 +629,7 b' static PyObject *compute_phases_map_sets' | |||
|
629 | 629 | PyObject *phaseset = NULL; |
|
630 | 630 | PyObject *phasessetlist = NULL; |
|
631 | 631 | PyObject *rev = NULL; |
|
632 |
Py_ssize_t len = index_length(self) |
|
|
632 | Py_ssize_t len = index_length(self); | |
|
633 | 633 | Py_ssize_t numphase = 0; |
|
634 | 634 | Py_ssize_t minrevallphases = 0; |
|
635 | 635 | Py_ssize_t minrevphase = 0; |
@@ -740,7 +740,7 b' static PyObject *index_headrevs(indexObj' | |||
|
740 | 740 | } |
|
741 | 741 | } |
|
742 | 742 | |
|
743 |
len = index_length(self) |
|
|
743 | len = index_length(self); | |
|
744 | 744 | heads = PyList_New(0); |
|
745 | 745 | if (heads == NULL) |
|
746 | 746 | goto bail; |
@@ -844,7 +844,7 b' static PyObject *index_deltachain(indexO' | |||
|
844 | 844 | int stoprev, iterrev, baserev = -1; |
|
845 | 845 | int stopped; |
|
846 | 846 | PyObject *chain = NULL, *result = NULL; |
|
847 | const Py_ssize_t length = index_length(self); | |
|
847 | const Py_ssize_t length = index_length(self) + 1; | |
|
848 | 848 | |
|
849 | 849 | if (!PyArg_ParseTuple(args, "iOi", &rev, &stoparg, &generaldelta)) { |
|
850 | 850 | return NULL; |
@@ -1098,7 +1098,7 b' static int nt_init(indexObject *self)' | |||
|
1098 | 1098 | return -1; |
|
1099 | 1099 | } |
|
1100 | 1100 | self->ntlength = 1; |
|
1101 |
self->ntrev = (int)index_length(self) |
|
|
1101 | self->ntrev = (int)index_length(self); | |
|
1102 | 1102 | self->ntlookups = 1; |
|
1103 | 1103 | self->ntmisses = 0; |
|
1104 | 1104 | if (nt_insert(self, nullid, -1) == -1) { |
@@ -1393,7 +1393,7 b' static int index_contains(indexObject *s' | |||
|
1393 | 1393 | |
|
1394 | 1394 | if (PyInt_Check(value)) { |
|
1395 | 1395 | long rev = PyInt_AS_LONG(value); |
|
1396 | return rev >= -1 && rev < index_length(self); | |
|
1396 | return rev >= -1 && rev < index_length(self) + 1; | |
|
1397 | 1397 | } |
|
1398 | 1398 | |
|
1399 | 1399 | if (node_check(value, &node) == -1) |
@@ -1673,7 +1673,7 b' static PyObject *index_commonancestorshe' | |||
|
1673 | 1673 | revs = PyMem_Malloc(argcount * sizeof(*revs)); |
|
1674 | 1674 | if (argcount > 0 && revs == NULL) |
|
1675 | 1675 | return PyErr_NoMemory(); |
|
1676 |
len = index_length(self) |
|
|
1676 | len = index_length(self); | |
|
1677 | 1677 | |
|
1678 | 1678 | for (i = 0; i < argcount; i++) { |
|
1679 | 1679 | static const int capacity = 24; |
@@ -1795,7 +1795,7 b' static void nt_invalidate_added(indexObj' | |||
|
1795 | 1795 | static int index_slice_del(indexObject *self, PyObject *item) |
|
1796 | 1796 | { |
|
1797 | 1797 | Py_ssize_t start, stop, step, slicelength; |
|
1798 | Py_ssize_t length = index_length(self); | |
|
1798 | Py_ssize_t length = index_length(self) + 1; | |
|
1799 | 1799 | int ret = 0; |
|
1800 | 1800 | |
|
1801 | 1801 | /* Argument changed from PySliceObject* to PyObject* in Python 3. */ |
@@ -69,7 +69,7 b' def _importfrom(pkgname, modname):' | |||
|
69 | 69 | (r'cext', r'bdiff'): 3, |
|
70 | 70 | (r'cext', r'mpatch'): 1, |
|
71 | 71 | (r'cext', r'osutil'): 4, |
|
72 |
(r'cext', r'parsers'): |
|
|
72 | (r'cext', r'parsers'): 7, | |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | # map import request to other package or module |
@@ -39,7 +39,7 b' def offset_type(offset, type):' | |||
|
39 | 39 | |
|
40 | 40 | class BaseIndexObject(object): |
|
41 | 41 | def __len__(self): |
|
42 |
return self._lgt + len(self._extra) |
|
|
42 | return self._lgt + len(self._extra) | |
|
43 | 43 | |
|
44 | 44 | def append(self, tup): |
|
45 | 45 | self._extra.append(tup) |
@@ -47,12 +47,12 b' class BaseIndexObject(object):' | |||
|
47 | 47 | def _fix_index(self, i): |
|
48 | 48 | if not isinstance(i, int): |
|
49 | 49 | raise TypeError("expecting int indexes") |
|
50 | if i < 0 or i >= len(self): | |
|
50 | if i < 0 or i >= len(self) + 1: | |
|
51 | 51 | raise IndexError |
|
52 | 52 | return i |
|
53 | 53 | |
|
54 | 54 | def __getitem__(self, i): |
|
55 |
if i == -1 or i == len(self) |
|
|
55 | if i == -1 or i == len(self): | |
|
56 | 56 | return (0, 0, 0, -1, -1, -1, -1, nullid) |
|
57 | 57 | i = self._fix_index(i) |
|
58 | 58 | if i >= self._lgt: |
@@ -210,7 +210,7 b' class repoview(object):' | |||
|
210 | 210 | unfichangelog = unfi.changelog |
|
211 | 211 | # bypass call to changelog.method |
|
212 | 212 | unfiindex = unfichangelog.index |
|
213 |
unfilen = len(unfiindex) |
|
|
213 | unfilen = len(unfiindex) | |
|
214 | 214 | unfinode = unfiindex[unfilen - 1][7] |
|
215 | 215 | |
|
216 | 216 | revs = filterrevs(unfi, self.filtername, self._visibilityexceptions) |
@@ -791,10 +791,8 b' indexformatv0_pack = indexformatv0.pack' | |||
|
791 | 791 | indexformatv0_unpack = indexformatv0.unpack |
|
792 | 792 | |
|
793 | 793 | class revlogoldindex(list): |
|
794 | def __len__(self): | |
|
795 | return list.__len__(self) + 1 | |
|
796 | 794 | def __getitem__(self, i): |
|
797 |
if i == -1 or i == len(self) |
|
|
795 | if i == -1 or i == len(self): | |
|
798 | 796 | return (0, 0, 0, -1, -1, -1, -1, nullid) |
|
799 | 797 | return list.__getitem__(self, i) |
|
800 | 798 | |
@@ -1066,11 +1064,11 b' class revlog(object):' | |||
|
1066 | 1064 | yield fp |
|
1067 | 1065 | |
|
1068 | 1066 | def tip(self): |
|
1069 |
return self.node(len(self.index) - |
|
|
1067 | return self.node(len(self.index) - 1) | |
|
1070 | 1068 | def __contains__(self, rev): |
|
1071 | 1069 | return 0 <= rev < len(self) |
|
1072 | 1070 | def __len__(self): |
|
1073 |
return len(self.index) |
|
|
1071 | return len(self.index) | |
|
1074 | 1072 | def __iter__(self): |
|
1075 | 1073 | return iter(pycompat.xrange(len(self))) |
|
1076 | 1074 | def revs(self, start=0, stop=None): |
@@ -1139,7 +1137,7 b' class revlog(object):' | |||
|
1139 | 1137 | i = self.index |
|
1140 | 1138 | p = self._nodepos |
|
1141 | 1139 | if p is None: |
|
1142 |
p = len(i) - |
|
|
1140 | p = len(i) - 1 | |
|
1143 | 1141 | else: |
|
1144 | 1142 | assert p < len(i) |
|
1145 | 1143 | for r in pycompat.xrange(p, -1, -1): |
General Comments 0
You need to be logged in to leave comments.
Login now