# HG changeset patch # User Pierre-Yves David # Date 2011-11-10 23:16:53 # Node ID a667c89e49b36906a0aa0caf5a7f2452f24d1b62 # Parent 0b7ce2f739fbde0057e820b56bbf8f0185a1a1f2 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 filterunknown(repo, phaseroots=None) def advanceboundary(repo, targetphase, nodes): """Add nodes to a phase changing other nodes phases if necessary. - Simplify boundary to contains phase roots only.""" + This function move boundary *forward* this means that all nodes are set + in the target phase or kept in a *lower* phase. - # move roots of lower states + Simplify boundary to contains phase roots only.""" 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 @@ def advanceboundary(repo, targetphase, n 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 +