stablesort: allow a callback to be triggered on merge
Storing some information as we sort is going to be useful to avoid performing
multiple sort while computing the stablerange.
--- a/hgext3rd/evolve/stablerange.py Fri Mar 24 03:33:36 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py Fri Mar 24 03:22:56 2017 +0100
@@ -46,7 +46,7 @@
displayer.flush(ctx)
displayer.close()
-def stablesort(repo, revs):
+def stablesort(repo, revs, mergecallback=None):
"""return '::revs' topologically sorted in "stable" order
This is a depth first traversal starting from 'nullrev', using node as a
@@ -113,6 +113,8 @@
assert not seen[current]
seen[current] = True
result.append(current) # could be yield, cf earlier comment
+ if mergecallback is not None and p2 != nullrev:
+ mergecallback(result, current)
cs = children[current]
if not cs:
current = None