stablerange: use first merge cache to skip over linear section
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 18 Dec 2017 20:04:50 +0100
changeset 3333 96d1cf475c19
parent 3332 7d4c157b6519
child 3334 db8feb404792
stablerange: use first merge cache to skip over linear section If we are to skip over a large section of the range, skipping everything until the first merge seems like a good idea.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Wed Dec 20 20:46:10 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Mon Dec 18 20:04:50 2017 +0100
@@ -449,6 +449,7 @@
         """Compute subrange unique to the exclusive part of merge"""
         result = []
         depth = repo.depthcache.get
+        nextmerge = repo.firstmergecache.get
         walkfrom = functools.partial(self._sortcache.walkfrom, repo)
         getjumps = functools.partial(self._sortcache.getjumps, repo)
         skips = depth(headrev) - slicepoint
@@ -464,12 +465,15 @@
 
         # utility function to find the next changeset with jump information
         # (and the distance to it)
-        def nextmerge(startrev):
-            for idx, rev in enumerate(walkfrom(startrev)):
-                if getjumps(rev) is not None:
-                    return idx, rev
-            idx += 1
-            return idx, None
+        def nextmergedata(startrev):
+            merge = nextmerge(startrev)
+            depthrev = depth(startrev)
+            if merge == startrev:
+                return 0, startrev
+            elif merge == nodemod.nullrev:
+                return depthrev, None
+            depthmerge = depth(merge)
+            return depthrev - depthmerge, merge
 
         # skip over all necesary data
         mainjump = None
@@ -510,7 +514,7 @@
         while size < tomap:
             assert mainjump is not None
             if refjumps is None:
-                dist2merge, merge = nextmerge(jumphead)
+                dist2merge, merge = nextmergedata(jumphead)
                 if (mainsize <= dist2merge) or merge is None:
                     refjumps = iter(())
                     ref = None