changeset 3327:0abc8fb7f49f

stablerange: compute jump size after jump retrieval only This prepares the caching of jump sizes.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 20 Dec 2017 17:49:41 +0100
parents 8ebd31af1452
children ff262ae59541
files hgext3rd/evolve/stablerange.py
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/stablerange.py	Sun Dec 10 03:49:48 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Wed Dec 20 17:49:41 2017 +0100
@@ -486,12 +486,12 @@
         while 0 < skips:
             jumphead = jumpdest
             currentjump = next(jumps)
-            jumppoint = currentjump[0]
+            skipped = size = until(jumphead, currentjump[0])
             jumpdest = currentjump[1]
-            skipped = size = until(jumphead, jumppoint)
             if size == skips:
+                jumphead = jumpdest
                 mainjump = next(jumps)
-                jumphead = jumpdest
+                mainsize = until(jumphead, mainjump[0])
             elif skips < size:
                 revs = walkfrom(jumphead)
                 next(revs)
@@ -501,12 +501,14 @@
                 skipped = skips
                 size -= skips
                 mainjump = currentjump
+                mainsize = size
             skips -= skipped
         assert skips == 0, skips
 
         # exiting from the previous block we should have:
         # jumphead: first non-skipped revision (head of the high subrange)
         # mainjump: next jump coming jump on main iteration
+        # mainsize: len(mainjump[0]::jumphead)
 
         # Now we need to compare walk on the main iteration with walk from the
         # current subrange head. Instead of doing a full walk, we just skim
@@ -518,21 +520,22 @@
             assert mainjump is not None
             if refjumps is None:
                 dist2merge, merge = nextmerge(jumphead)
-                dist2jump = until(jumphead, mainjump[0])
-                if (dist2jump <= dist2merge) or merge is None:
+                if (mainsize <= dist2merge) or merge is None:
                     refjumps = iter(())
                     ref = None
                 else:
                     # advance counters
                     size += dist2merge
+                    mainsize -= dist2merge
                     jumphead = merge
                     refjumps = iter(getjumps(merge))
                     ref = next(refjumps, None)
             elif mainjump == ref:
                 # both follow the same path
-                size += until(jumphead, ref[0])
+                size += mainsize
                 jumphead = mainjump[1]
                 mainjump = next(jumps, None)
+                mainsize = until(jumphead, mainjump[0])
                 ref = next(refjumps, None)
                 if ref is None:
                     # we are doing with section specific to the last merge
@@ -540,7 +543,7 @@
                     # next merge
                     refjumps = None
             else:
-                size += until(jumphead, mainjump[0])
+                size += mainsize
                 if size < tomap:
                     subrange = (rangehead, depth(rangehead) - size)
                     assert subrange[1] < depth(subrange[0])
@@ -549,6 +552,7 @@
                     size = 0
                     jumphead = rangehead = mainjump[1]
                     mainjump = next(jumps, None)
+                    mainsize = until(jumphead, mainjump[0])
                     refjumps = None
 
         if tomap: