changeset 38849:da5a666f0f78

pure: create type for revlog v0 index The new type takes care of hiding the nullid entry. This type helps us transition away from including that entry at index[len(index)-1]. Differential Revision: https://phab.mercurial-scm.org/D4020
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 20 Jul 2018 14:25:59 -0700
parents c0d411ea6639
children 6104b203bec8
files mercurial/revlog.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri Jul 20 10:02:05 2018 -0700
+++ b/mercurial/revlog.py	Fri Jul 20 14:25:59 2018 -0700
@@ -790,6 +790,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
@@ -811,10 +819,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]):