evolve: extract the code computing dependencies in a separate function
authorLaurent Charignon <lcharignon@fb.com>
Thu, 04 Jun 2015 16:49:16 -0700
changeset 1361 043e5ca9322f
parent 1360 5c13945b32fc
child 1362 73e5b5280c1c
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.
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