[PATCH 5 of 5] phases: retractboundary should update all affected phases

Durham Goode durham at fb.com
Thu Oct 9 14:22:43 CDT 2014

# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1412707733 25200
#      Tue Oct 07 11:48:53 2014 -0700
# Node ID be5f4f8f38440da11821946ae84abfb199190656
# Parent  80710688335b3e647bbf74700cb6e1a464b909b2
phases: retractboundary should update all affected phases

Previously retractboundary only updated the roots for the phase it was changing.
This meant there might be other roots in other phases that were now incorrect.
It just happened to work fine, because the old algorithms allowed future phases
to overwrite the results of earlier phases.  The upcoming new phase algorithm
requires the roots to be correct, so this patch fixes up all roots affected by
the boundary retracting.

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -287,7 +287,18 @@ class phasecache(object):
                 raise util.Abort(_('cannot change null revision phase'))
             currentroots = currentroots.copy()
-            ctxs = repo.set('roots(%ln::)', currentroots)
+            affectedrevs = repo.revs('%ln::', currentroots)
+            for phase, roots in enumerate(self.phaseroots):
+                if targetphase <= phase:
+                    continue
+                roots = roots.copy()
+                for rev in affectedrevs:
+                    node = repo.changelog.node(rev)
+                    if node in roots:
+                        roots.discard(node)
+                self._updateroots(phase, roots, tr)
+            ctxs = repo.set('roots(%ld)', affectedrevs)
             currentroots.intersection_update(ctx.node() for ctx in ctxs)
             self._updateroots(targetphase, currentroots, tr)

More information about the Mercurial-devel mailing list