changeset 33452:7b25a56366cf

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.
author Boris Feld <boris.feld@octobus.net>
date Mon, 10 Jul 2017 23:50:16 +0200
parents e44d54260c32
children f6b7617a85bb
files mercurial/phases.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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