[PATCH 4 of 6 phases exchange V2] phases: add a function to compute heads from root

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Thu Dec 15 05:05:49 CST 2011


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1323911904 -3600
# Node ID dbc6f1e57a431cc47ce3c98dcc04d893a8f4fd57
# Parent  f1a13423d9c1e10a28104aeed157e8b5d0b025a2
phases: add a function to compute heads from root

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -142,5 +142,32 @@ def pushphase(repo, nhex, oldphasestr, n
             return 1
         else:
             return 0
     finally:
         lock.release()
+
+def analyzeremotephases(repo, subset, roots):
+    """Compute phases heads and root in a subset of node from root dict
+
+    * subset is heads of the subset
+    * roots is {<nodeid> => phase} mapping. key and value are string.
+
+    Accept unknown element input
+    """
+    # build list from dictionary
+    phaseroots = [[] for p in allphases]
+    for nhex, phase in roots.iteritems():
+        if nhex == 'publishing': # ignore data related to publish option
+            continue
+        node = bin(nhex)
+        phase = int(phase)
+        if node in repo:
+            phaseroots[phase].append(node)
+    # compute heads
+    phaseheads = [[] for p in allphases]
+    for phase in allphases[:-1]:
+        toproof = phaseroots[phase + 1]
+        revset = repo.set('heads((%ln + parents(%ln)) - (%ln::%ln))',
+                          subset, toproof, toproof, subset)
+        phaseheads[phase].extend(c.node() for c in revset)
+    return phaseheads, phaseroots
+


More information about the Mercurial-devel mailing list