Patchwork [1,of,8,V3] revlog: fix pure python slicing test when chain contains nullrev

login
register
mail settings
Submitter Boris Feld
Date Dec. 28, 2018, 6:12 p.m.
Message ID <e7865a9776d5f676b2c4.1546020767@pc62.home>
Download mbox | patch
Permalink /patch/37378/
State Accepted
Headers show

Comments

Boris Feld - Dec. 28, 2018, 6:12 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1545296356 -3600
#      Thu Dec 20 09:59:16 2018 +0100
# Node ID e7865a9776d5f676b2c49390e533bca293be6f9e
# Parent  ef54bd33b47604f82a85cd0a68de71741f56c345
# EXP-Topic sparse-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e7865a9776d5
revlog: fix pure python slicing test when chain contains nullrev

The revlog moke used in the test was not behaving the same as its C counterpart.
Yuya Nishihara - Dec. 30, 2018, 8:37 a.m.
On Fri, 28 Dec 2018 19:12:47 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1545296356 -3600
> #      Thu Dec 20 09:59:16 2018 +0100
> # Node ID e7865a9776d5f676b2c49390e533bca293be6f9e
> # Parent  ef54bd33b47604f82a85cd0a68de71741f56c345
> # EXP-Topic sparse-revlog
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e7865a9776d5
> revlog: fix pure python slicing test when chain contains nullrev

Queued 1 and 3, thanks.

Patch

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -47,11 +47,15 @@  class _testrevlog(object):
         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 @@  class _testrevlog(object):
         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 @@  def slicechunk(revlog, revs, targetsize=
     [[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)