stablesort: record previous segment size in the jump
That was, we can skip over a full jump without walking it. We'll make use of
this in the next changeset.
--- a/hgext3rd/evolve/stablerange.py Wed Dec 20 17:59:14 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py Wed Dec 20 17:56:38 2017 +0100
@@ -530,7 +530,7 @@
jumphead = merge
refjumps = iter(getjumps(merge))
ref = next(refjumps, None)
- elif mainjump == ref:
+ elif ref is not None and mainjump[0:2] == ref[0:2]:
# both follow the same path
size += mainsize
jumphead = mainjump[1]
--- a/hgext3rd/evolve/stablesort.py Wed Dec 20 17:59:14 2017 +0100
+++ b/hgext3rd/evolve/stablesort.py Wed Dec 20 17:56:38 2017 +0100
@@ -405,8 +405,8 @@
rev = current
jumps = []
- def recordjump(source, destination):
- jump = (source, destination)
+ def recordjump(source, destination, size):
+ jump = (source, destination, size)
jumps.append(jump)
process = self._process_exclusive_side
for rev in process(lower_parent, higher_parent, cl, parents,
@@ -414,7 +414,7 @@
yield rev
if rev == current:
- recordjump(rev, lower_parent)
+ recordjump(rev, lower_parent, 1)
self._jumps[current] = jumps
@@ -445,6 +445,7 @@
hardstack.append(higher)
nextjump = False
+ size = 1 # take the merge point into account
while hardstack:
current = popready(hardstack)
if current in seen:
@@ -452,9 +453,11 @@
softstack = []
while current in bound and current not in seen:
if nextjump:
- recordjump(previous, current)
+ recordjump(previous, current, size)
nextjump = False
+ size = 0
yield current
+ size += 1
previous = current
seen.add(current)
@@ -487,8 +490,9 @@
# any in processed head has to go in the hard stack
nextjump = True
hardstack.extend(softstack)
+
if previous is not None:
- recordjump(previous, lower)
+ recordjump(previous, lower, size)
_methodmap = {
'branchpoint': stablesort_branchpoint,