diff hgext/evolve.py @ 1361:043e5ca9322f

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.
author Laurent Charignon <lcharignon@fb.com>
date Thu, 04 Jun 2015 16:49:16 -0700
parents 3bb7a080da4d
children f00d91365ab9
line wrap: on
line diff
--- 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