Patchwork [08,of,13] revlog: add a doctest for _segmentspan

login
register
mail settings
Submitter Boris Feld
Date July 10, 2018, 1:27 p.m.
Message ID <0b614560fb0e094311b8.1531229237@FB-lair>
Download mbox | patch
Permalink /patch/32747/
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 1531210726 -7200
#      Tue Jul 10 10:18:46 2018 +0200
# Node ID 0b614560fb0e094311b85e52fbe31c9c8d571b17
# Parent  a532d65e9c8b5a27679a4400179a2c9c87c18fda
# EXP-Topic write-for-sparse-read
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0b614560fb0e
revlog: add a doctest for _segmentspan

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -269,6 +269,25 @@  def _segmentspan(revlog, revs):
     """Get the byte span of a segment of revisions
 
     revs is a sorted array of revision numbers
+
+    >>> revlog = _testrevlog([
+    ...  5,  #0
+    ...  10, #1
+    ...  12, #2
+    ...  12, #3 (empty)
+    ...  17, #4
+    ... ])
+
+    >>> _segmentspan(revlog, [0, 1, 2, 3, 4])
+    17
+    >>> _segmentspan(revlog, [0, 4])
+    17
+    >>> _segmentspan(revlog, [3, 4])
+    5
+    >>> _segmentspan(revlog, [1, 2, 3,])
+    7
+    >>> _segmentspan(revlog, [1, 3])
+    7
     """
     if not revs:
         return 0