# HG changeset patch # User Laurent Charignon # Date 1433461756 25200 # Node ID 043e5ca9322fc92cd90b9ff3dc462bcbfbd3c095 # Parent 5c13945b32fc4bcb4998a1bdd0b669ac43c26574 evolve: extract the code computing dependencies in a separate function The code to compute dependencies between unstable changeset can be reused to compute the next reveset. This patch extracts it in its own function to make it reusable. diff -r 5c13945b32fc -r 043e5ca9322f hgext/evolve.py --- a/hgext/evolve.py Thu Jun 04 10:01:02 2015 -0700 +++ b/hgext/evolve.py Thu Jun 04 16:49:16 2015 -0700 @@ -1254,20 +1254,10 @@ raise util.Abort(_("conflict rewriting. can't choose destination\n")) return repo[newer[0][0]].rev() -def orderrevs(repo, revs): - """ Compute an ordering to solve instability for the given revs - - - Takes revs a list of instable revisions - - - Returns the same revisions ordered to solve their instability from the - bottom to the top of the stack that the stabilization process will produce - eventually. - - This ensure the minimal number of stabilization as we can stabilize each - revision on its final, stabilized, destination. - """ - - # Step 1: Build the dependency graph +def builddependencies(repo, revs): + """ returns dependency graphs giving an order to solve instability of revs + (see orderrevs for more information on usage) """ + # For each troubled revision we keep track of what instability if any should # be resolved in order to resolve it. Example: # dependencies = {3: [6], 6:[]} @@ -1283,7 +1273,22 @@ if succ in revs: dependencies[r].add(succ) rdependencies[succ].add(r) - + return dependencies, rdependencies + +def orderrevs(repo, revs): + """ Compute an ordering to solve instability for the given revs + + - Takes revs a list of instable revisions + + - Returns the same revisions ordered to solve their instability from the + bottom to the top of the stack that the stabilization process will produce + eventually. + + This ensure the minimal number of stabilization as we can stabilize each + revision on its final, stabilized, destination. + """ + # Step 1: Build the dependency graph + dependencies, rdependencies = builddependencies(repo, revs) # Step 2: Build the ordering # Remove the revisions with no dependency(A) and add them to the ordering. # Removing these revisions leads to new revisions with no dependency (the