stablesort: allow a callback to be triggered on merge
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 24 Mar 2017 03:22:56 +0100
changeset 2212 afb35ad42040
parent 2211 ecb46c7ee281
child 2213 fb2937b0dd49
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.
hgext3rd/evolve/stablerange.py
--- 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