[PATCH 04 of 11] phases: extract the core of boundary retraction in '_retractboundary'

Boris Feld boris.feld at octobus.net
Fri Jul 14 09:25:38 EDT 2017


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1499723416 -7200
#      Mon Jul 10 23:50:16 2017 +0200
# Node ID 2a23f55b1b3487c7d43c0709efa900c01235b3cf
# Parent  d578e17d880990375cf64d4c026e927987211fe7
# EXP-Topic tr.changes.phases
phases: extract the core of boundary retraction in '_retractboundary'

At the moment the 'retractboundary' function is called for multiple reasons:

First, actually retracting boundaries. There are only two cases for theses:
'hg phase --force' and 'hg qimport'. This will need extra graph computation to
retrieve the phase changes.

Second, setting the phases of newly added changesets. In this case we already
know all the affected nodes and we just needs to register different
information (old phase is None).

Third, when reducing the set of roots when advancing phase. The phase are
already properly tracked so we do not needs anything else in this case.

To deal with this difference in phase tracking, we extract the core logic into
a private method that all three cases can use.

diff -r d578e17d8809 -r 2a23f55b1b34 mercurial/phases.py
--- a/mercurial/phases.py	Tue Jul 11 02:39:52 2017 +0200
+++ b/mercurial/phases.py	Mon Jul 10 23:50:16 2017 +0200
@@ -331,10 +331,14 @@
                 delroots.extend(olds - roots)
         # declare deleted root in the target phase
         if targetphase != 0:
-            self.retractboundary(repo, tr, targetphase, delroots)
+            self._retractboundary(repo, tr, targetphase, delroots)
         repo.invalidatevolatilesets()
 
     def retractboundary(self, repo, tr, targetphase, nodes):
+        self._retractboundary(repo, tr, targetphase, nodes)
+        repo.invalidatevolatilesets()
+
+    def _retractboundary(self, repo, tr, targetphase, nodes):
         # Be careful to preserve shallow-copied values: do not update
         # phaseroots values, replace them.
 
@@ -343,6 +347,7 @@
         newroots = [n for n in nodes
                     if self.phase(repo, repo[n].rev()) < targetphase]
         if newroots:
+
             if nullid in newroots:
                 raise error.Abort(_('cannot change null revision phase'))
             currentroots = currentroots.copy()
@@ -360,7 +365,6 @@
             finalroots.update(ctx.node() for ctx in updatedroots)
 
             self._updateroots(targetphase, finalroots, tr)
-        repo.invalidatevolatilesets()
 
     def filterunknown(self, repo):
         """remove unknown nodes from the phase boundary


More information about the Mercurial-devel mailing list