changeset 2235:eadb1c69e350

stablerange: support loading the cache iteratively We record how far we loaded so that we can resume from this point.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 24 Mar 2017 11:27:56 +0100
parents 16a5a37ced62
children c0e2ba85e76a
files hgext3rd/evolve/stablerange.py
diffstat 1 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/stablerange.py	Fri Mar 24 11:20:42 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Fri Mar 24 11:27:56 2017 +0100
@@ -225,6 +225,9 @@
 class stablerange(object):
 
     def __init__(self):
+        # The point up to which we have data in cache
+        self._tiprev = None
+        self._tipnode = None
         # cache the 'depth' of a changeset, the size of '::rev'
         self._depthcache = {}
         # cache the standard stable subranges or a range
@@ -249,6 +252,7 @@
     def warmup(self, repo, upto=None):
         """warm the cache up"""
         repo = repo.unfiltered()
+        cl = repo.changelog
         # subrange should be warmed from head to range to be able to benefit
         # from revsfromrange cache. otherwise each merge will trigger its own
         # stablesort.
@@ -256,12 +260,17 @@
         # we use the revnumber as an approximation for depth
         ui = repo.ui
 
-        if upto:
-            revs = repo.changelog.revs(stop=upto)
+        if upto is None:
+            upto = len(cl) - 1
+        if self._tiprev is None:
+            revs = cl.revs(stop=upto)
             nbrevs = upto + 1
         else:
-            revs = list(repo.changelog.revs())
-            nbrevs = len(repo.changelog)
+            assert cl.node(self._tiprev) == self._tipnode
+            if upto <= self._tiprev:
+                return
+            revs = cl.revs(start=self._tiprev + 1, stop=upto)
+            nbrevs = upto - self._tiprev
         rangeheap = []
         for idx, r in enumerate(revs):
             if not idx % 1000:
@@ -292,6 +301,9 @@
                         heappush(rangeheap, (-sub[0], sub))
         ui.progress(_("filling stablerange cache"), None, total=nbrevs)
 
+        self._tiprev = upto
+        self._tipnode = cl.node(upto)
+
     def depthrev(self, repo, rev):
         repo = repo.unfiltered()
         cl = repo.changelog