Patchwork [02,of,10,V2] doctest: add a `issnapshot` method to _testrevlog

login
register
mail settings
Submitter Boris Feld
Date Nov. 15, 2018, 10:38 a.m.
Message ID <2251b59ed38df5764429.1542278320@localhost.localdomain>
Download mbox | patch
Permalink /patch/36592/
State Accepted
Headers show

Comments

Boris Feld - Nov. 15, 2018, 10:38 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542117989 -3600
#      Tue Nov 13 15:06:29 2018 +0100
# Node ID 2251b59ed38df5764429e9b924eee57c4a7babae
# Parent  41e1b825755ee209effb3cd997edd680e6cc4145
# EXP-Topic sparse-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2251b59ed38d
doctest: add a `issnapshot` method to _testrevlog

We'll need it soon.

Patch

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -38,11 +38,12 @@  LIMIT_DELTA2TEXT = 2
 class _testrevlog(object):
     """minimalist fake revlog to use in doctests"""
 
-    def __init__(self, data, density=0.5, mingap=0):
+    def __init__(self, data, density=0.5, mingap=0, snapshot=()):
         """data is an list of revision payload boundaries"""
         self._data = data
         self._srdensitythreshold = density
         self._srmingapsize = mingap
+        self._snapshot = set(snapshot)
 
     def start(self, rev):
         if rev == 0:
@@ -58,6 +59,9 @@  class _testrevlog(object):
     def __len__(self):
         return len(self._data)
 
+    def issnapshot(self, rev):
+        return rev in self._snapshot
+
 def slicechunk(revlog, revs, targetsize=None):
     """slice revs to reduce the amount of unrelated data to be read from disk.