[PATCH 3 of 7 phases V2] phases: add retractboundary function to move boundary backward
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Nov 10 23:26:06 UTC 2011
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1320967013 -3600
# Node ID 264f24de2c993ac1478f81dfc731bde37789037b
# Parent 15f7a40ad734fcc192941bf2901c30b177d8d9f1
phases: add retractboundary function to move boundary backward
The advanceboundary documentation is updated to highlight the difference.
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -61,9 +61,10 @@
def advanceboundary(repo, targetphase, nodes):
"""Add nodes to a phase changing other nodes phases if necessary.
+ This function move boundary *forward* this means that all nodes are set
+ in the target phase or kept in a *lower* phase.
+
Simplify boundary to contains phase roots only."""
-
- # move roots of lower states
for phase in xrange(targetphase + 1, len(allphases)):
# filter nodes that are not in a compatible phase already
# XXX rev phase cache might have been invalidated by a previous loop
@@ -81,3 +82,21 @@
if '_phaserev' in vars(repo):
del repo._phaserev
repo._dirtyphases = True
+
+def retractboundary(repo, targetphase, nodes):
+ """Set nodes back to a phase changing other nodes phases if necessary.
+
+ This function move boundary *backward* this means that all nodes are set
+ in the target phase or kept in a *higher* phase.
+
+ Simplify boundary to contains phase roots only."""
+ currentroots = repo._phaseroots[targetphase]
+ newroots = [n for n in nodes if repo[n].phase() < targetphase]
+ if newroots:
+ currentroots.update(newroots)
+ ctxs = repo.set('roots(%ln::)', currentroots)
+ currentroots.intersection_update(ctx.node() for ctx in ctxs)
+ if '_phaserev' in vars(repo):
+ del repo._phaserev
+ repo._dirtyphases = True
+
More information about the Mercurial-devel
mailing list