[PATCH 1 of 2 evolve-ext] evolve: extract the code computing dependencies in a separate function

Laurent Charignon lcharignon at fb.com
Thu Jun 4 19:06:07 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1433461756 25200
#      Thu Jun 04 16:49:16 2015 -0700
# Node ID 6910cd198dd7824af651d72b224cf66966f59788
# 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 --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -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


More information about the Mercurial-devel mailing list