Patchwork [09,of,13] revlog: document and test _slicechunk

login
register
mail settings
Submitter Boris Feld
Date July 10, 2018, 1:27 p.m.
Message ID <80bd86f57f8a877cf0ab.1531229238@FB-lair>
Download mbox | patch
Permalink /patch/32749/
State Accepted
Headers show

Comments

Boris Feld - July 10, 2018, 1:27 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1531211673 -7200
#      Tue Jul 10 10:34:33 2018 +0200
# Node ID 80bd86f57f8a877cf0ab43623dde9e9caf6ece20
# Parent  0b614560fb0e094311b85e52fbe31c9c8d571b17
# EXP-Topic write-for-sparse-read
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 80bd86f57f8a
revlog: document and test _slicechunk

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -298,6 +298,40 @@  def _slicechunk(revlog, revs):
 
     ``revs`` is sliced into groups that should be read in one time.
     Assume that revs are sorted.
+
+    The initial chunk is sliced until the overall density (payload/chunks-span
+    ratio) is above `revlog._srdensitythreshold`. No gap smaller than
+    `revlog._srmingapsize` is skipped.
+
+    >>> revlog = _testrevlog([
+    ...  5,  #00 (5)
+    ...  10, #01 (5)
+    ...  12, #02 (2)
+    ...  12, #03 (empty)
+    ...  27, #04 (15)
+    ...  31, #05 (4)
+    ...  31, #06 (empty)
+    ...  42, #07 (11)
+    ...  47, #08 (5)
+    ...  47, #09 (empty)
+    ...  48, #10 (1)
+    ...  51, #11 (3)
+    ...  74, #12 (23)
+    ...  85, #13 (11)
+    ...  86, #14 (1)
+    ...  91, #15 (5)
+    ... ])
+
+    >>> list(_slicechunk(revlog, range(16)))
+    [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]
+    >>> list(_slicechunk(revlog, [0, 15]))
+    [[0], [15]]
+    >>> list(_slicechunk(revlog, [0, 11, 15]))
+    [[0], [11], [15]]
+    >>> list(_slicechunk(revlog, [0, 11, 13, 15]))
+    [[0], [11, 13, 15]]
+    >>> list(_slicechunk(revlog, [1, 2, 3, 5, 8, 10, 11, 14]))
+    [[1, 2], [5, 8, 10, 11], [14]]
     """
     start = revlog.start
     length = revlog.length