Patchwork D4020: pure: create type for revlog v0 index

login
register
mail settings
Submitter phabricator
Date Aug. 2, 2018, 4:40 a.m.
Message ID <12b0b43cb6eca75975a5826ecc7bd564@localhost.localdomain>
Download mbox | patch
Permalink /patch/33093/
State Not Applicable
Headers show

Comments

phabricator - Aug. 2, 2018, 4:40 a.m.
martinvonz updated this revision to Diff 9779.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4020?vs=9720&id=9779

REVISION DETAIL
  https://phab.mercurial-scm.org/D4020

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - Aug. 4, 2018, 4 a.m.
Queued up to this, thanks. Can you rebase the remainder?
phabricator - Aug. 4, 2018, 4:05 a.m.
yuja added a comment.


  Queued up to this, thanks. Can you rebase the remainder?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4020

To: martinvonz, indygreg, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -789,6 +789,14 @@ 
 indexformatv0_pack = indexformatv0.pack
 indexformatv0_unpack = indexformatv0.unpack
 
+class revlogoldindex(list):
+    def __len__(self):
+        return list.__len__(self) + 1
+    def __getitem__(self, i):
+        if i == -1 or i == len(self) - 1:
+            return (0, 0, 0, -1, -1, -1, -1, nullid)
+        return list.__getitem__(self, i)
+
 class revlogoldio(object):
     def __init__(self):
         self.size = indexformatv0.size
@@ -810,10 +818,7 @@ 
             nodemap[e[6]] = n
             n += 1
 
-        # add the magic null revision at -1
-        index.append((0, 0, 0, -1, -1, -1, -1, nullid))
-
-        return index, nodemap, None
+        return revlogoldindex(index), nodemap, None
 
     def packentry(self, entry, node, version, rev):
         if gettype(entry[0]):