comparison mercurial/pure/parsers.py @ 38850:6104b203bec8

index: replace insert(-1, e) method by append(e) method I want to make index[len(index) - 1] be the tip revision, not null revision as it is today. insert(-1, e) will then make little sense. Since insert() currently requires the first argument to be -1, it seems simpler to replace it by a method that allows insertion only at the end. Note that revlogoldindex already has this method (by virtue of extending list). Differential Revision: https://phab.mercurial-scm.org/D4021
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 01 Aug 2018 10:57:14 -0700
parents c0d411ea6639
children 781b2720d2ac
comparison
equal deleted inserted replaced
38849:da5a666f0f78 38850:6104b203bec8
39 39
40 class BaseIndexObject(object): 40 class BaseIndexObject(object):
41 def __len__(self): 41 def __len__(self):
42 return self._lgt + len(self._extra) + 1 42 return self._lgt + len(self._extra) + 1
43 43
44 def insert(self, i, tup): 44 def append(self, tup):
45 assert i == -1
46 self._extra.append(tup) 45 self._extra.append(tup)
47 46
48 def _fix_index(self, i): 47 def _fix_index(self, i):
49 if not isinstance(i, int): 48 if not isinstance(i, int):
50 raise TypeError("expecting int indexes") 49 raise TypeError("expecting int indexes")