D4292: pure: fix pure-Python revlog to support [0] lookups on empty log
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Thu Aug 16 03:02:50 UTC 2018
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This fixes many many test failures in pure mode, but it appears to be a material behavior difference from the cext version. I tried adding this test:
def testindex0onemptyrevlog(self):
want = (0, 0, 0, -1, -1, -1, -1, nullid)
index, junk = parsers.parse_index2('', True)
got = index[0]
self.assertEqual(want, got)
to test-parseindex2.py, and it fails on native (but passes --pure
after this patch). I'm unclear what the correct behavior *should* be,
but hopefully this guides someone to a fix...
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4292
AFFECTED FILES
mercurial/pure/parsers.py
CHANGE DETAILS
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -52,7 +52,7 @@
return i
def __getitem__(self, i):
- if i == -1:
+ if i == -1 or i == len(self) == 0:
return (0, 0, 0, -1, -1, -1, -1, nullid)
i = self._fix_index(i)
if i >= self._lgt:
To: durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list