index: rename _fix_index() since it no longer fixes the index
Since c0d411ea6639 (index: drop support for negative indexes into the
index, 2018-07-20), it always returns the input (unless it raises).
Differential Revision: https://phab.mercurial-scm.org/D4334
--- a/mercurial/pure/parsers.py Sat Aug 18 00:01:31 2018 -0700
+++ b/mercurial/pure/parsers.py Sun Aug 19 22:30:32 2018 -0700
@@ -44,17 +44,16 @@
def append(self, tup):
self._extra.append(tup)
- def _fix_index(self, i):
+ def _check_index(self, i):
if not isinstance(i, int):
raise TypeError("expecting int indexes")
if i < 0 or i >= len(self):
raise IndexError
- return i
def __getitem__(self, i):
if i == -1:
return (0, 0, 0, -1, -1, -1, -1, nullid)
- i = self._fix_index(i)
+ self._check_index(i)
if i >= self._lgt:
return self._extra[i - self._lgt]
index = self._calculate_index(i)
@@ -79,7 +78,8 @@
def __delitem__(self, i):
if not isinstance(i, slice) or not i.stop == -1 or i.step is not None:
raise ValueError("deleting slices only supports a:-1 with step 1")
- i = self._fix_index(i.start)
+ i = i.start
+ self._check_index(i)
if i < self._lgt:
self._data = self._data[:i * indexsize]
self._lgt = i
@@ -113,7 +113,8 @@
def __delitem__(self, i):
if not isinstance(i, slice) or not i.stop == -1 or i.step is not None:
raise ValueError("deleting slices only supports a:-1 with step 1")
- i = self._fix_index(i.start)
+ i = i.start
+ self._check_index(i)
if i < self._lgt:
self._offsets = self._offsets[:i]
self._lgt = i