changeset 2233:e922cd76804a

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.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 24 Mar 2017 11:18:01 +0100
parents 6b95bcc402fe
children 16a5a37ced62
files hgext3rd/evolve/obsdiscovery.py hgext3rd/evolve/stablerange.py
diffstat 2 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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: