stablerange: warmup all upto a revision
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 24 Mar 2017 11:18:01 +0100
changeset 2233 e922cd76804a
parent 2232 6b95bcc402fe
child 2234 16a5a37ced62
stablerange: warmup all upto a revision Let us start doing more systemic warming of the cache before we start writing things out. This prepare on disk caching.
hgext3rd/evolve/obsdiscovery.py
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/obsdiscovery.py	Fri Mar 24 10:22:38 2017 +0100
+++ b/hgext3rd/evolve/obsdiscovery.py	Fri Mar 24 11:18:01 2017 +0100
@@ -398,7 +398,7 @@
     s = node.short
     revs = scmutil.revrange(repo, opts['rev'])
     # prewarm depth cache
-    repo.stablerange.warmup(repo, revs)
+    repo.stablerange.warmup(repo, max(revs))
     cl = repo.changelog
     rangelength = repo.stablerange.rangelength
     depthrev = repo.stablerange.depthrev
--- a/hgext3rd/evolve/stablerange.py	Fri Mar 24 10:22:38 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Fri Mar 24 11:18:01 2017 +0100
@@ -179,7 +179,7 @@
     depth = stablerange.depthrev
     length = stablerange.rangelength
     subranges = stablerange.subranges
-    repo.stablerange.warmup(repo, revs)
+    repo.stablerange.warmup(repo, max(revs))
     if opts['subranges']:
         ranges = subrangesclosure(repo, revs)
     else:
@@ -245,8 +245,8 @@
         # merge.
         self._inheritancecache = {}
 
-    def warmup(self, repo, heads):
-        """warm the cache up to 'heads'"""
+    def warmup(self, repo, upto=None):
+        """warm the cache up"""
         repo = repo.unfiltered()
         # subrange should be warmed from head to range to be able to benefit
         # from revsfromrange cache. otherwise each merge will trigger its own
@@ -255,8 +255,12 @@
         # we use the revnumber as an approximation for depth
         ui = repo.ui
 
-        revs = repo.revs("::%ld", heads)
-        nbrevs = len(revs)
+        if upto:
+            revs = repo.changelog.revs(stop=upto)
+            nbrevs = upto + 1
+        else:
+            revs = list(repo.changelog.revs())
+            nbrevs = len(repo.changelog)
         rangeheap = []
         for idx, r in enumerate(revs):
             if not idx % 1000: