changeset 41082:88d813cd9acd

revlog: fix pure python slicing test when chain contains nullrev The revlog mock used in the test was not behaving the same as its C counterpart.
author Boris Feld <boris.feld@octobus.net>
date Thu, 20 Dec 2018 09:59:16 +0100
parents 46e0563c67db
children 9d35ae3d9999
files mercurial/revlogutils/deltas.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/deltas.py	Sun Dec 30 17:31:57 2018 +0900
+++ b/mercurial/revlogutils/deltas.py	Thu Dec 20 09:59:16 2018 +0100
@@ -47,11 +47,15 @@
         self.index = None
 
     def start(self, rev):
+        if rev == nullrev:
+            return 0
         if rev == 0:
             return 0
         return self._data[rev - 1]
 
     def end(self, rev):
+        if rev == nullrev:
+            return 0
         return self._data[rev]
 
     def length(self, rev):
@@ -61,6 +65,8 @@
         return len(self._data)
 
     def issnapshot(self, rev):
+        if rev == nullrev:
+            return True
         return rev in self._snapshot
 
 def slicechunk(revlog, revs, targetsize=None):
@@ -116,6 +122,12 @@
     [[0], [11], [13], [15]]
     >>> list(slicechunk(revlog, [0, 11, 13, 15], targetsize=20))
     [[0], [11], [13, 15]]
+
+    Slicing involving nullrev
+    >>> list(slicechunk(revlog, [-1, 0, 11, 13, 15], targetsize=20))
+    [[-1, 0], [11], [13, 15]]
+    >>> list(slicechunk(revlog, [-1, 13, 15], targetsize=5))
+    [[-1], [13], [15]]
     """
     if targetsize is not None:
         targetsize = max(targetsize, revlog._srmingapsize)