[PATCH 09 of 11] phases: detect when boundaries has been actually retracted

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


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1499894109 -7200
#      Wed Jul 12 23:15:09 2017 +0200
# Node ID d90b8e445f0f48ebcac362fb1df6f5498f814f90
# Parent  c60ee8233517c9e84d5907ea2822f16667d31ca8
# EXP-Topic tr.changes.phases
phases: detect when boundaries has been actually retracted

It is useful to detect noop and avoid expensive operations in this case.

We return the information to inform the caller of a possible update. Top level
function might need to react to the phase update (eg: invalidating some
caches, tracking phase change).

diff -r c60ee8233517 -r d90b8e445f0f mercurial/phases.py
--- a/mercurial/phases.py	Tue Jul 11 01:17:36 2017 +0200
+++ b/mercurial/phases.py	Wed Jul 12 23:15:09 2017 +0200
@@ -357,6 +357,7 @@
 
         repo = repo.unfiltered()
         currentroots = self.phaseroots[targetphase]
+        finalroots = oldroots = set(currentroots)
         newroots = [n for n in nodes
                     if self.phase(repo, repo[n].rev()) < targetphase]
         if newroots:
@@ -376,8 +377,10 @@
             finalroots = set(n for n in currentroots if repo[n].rev() <
                              minnewroot)
             finalroots.update(ctx.node() for ctx in updatedroots)
-
+        if finalroots != oldroots:
             self._updateroots(targetphase, finalroots, tr)
+            return True
+        return False
 
     def filterunknown(self, repo):
         """remove unknown nodes from the phase boundary


More information about the Mercurial-devel mailing list