Patchwork [02,of,11] phases: extract the intermediate set of affected revs

login
register
mail settings
Submitter Boris Feld
Date July 14, 2017, 1:25 p.m.
Message ID <936da074fe26e4513367.1500038736@FB>
Download mbox | patch
Permalink /patch/22318/
State Accepted
Headers show

Comments

Boris Feld - July 14, 2017, 1:25 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499717921 -7200
#      Mon Jul 10 22:18:41 2017 +0200
# Node ID 936da074fe26e45133672419d670febbfdb447a8
# Parent  8c771f0d6e8d70b088abc2c31dc59be0d58ab9fa
# EXP-Topic tr.changes.phases
phases: extract the intermediate set of affected revs

When advancing phases, we compute the new roots for the phases above. During
this process, we need to compute all the revisions that change phases (to the
new target phases). Extract these revisions into a separate variable. This
will be useful to record the phase changes in the transaction.

Patch

diff -r 8c771f0d6e8d -r 936da074fe26 mercurial/phases.py
--- a/mercurial/phases.py	Mon Jul 10 22:22:42 2017 +0200
+++ b/mercurial/phases.py	Mon Jul 10 22:18:41 2017 +0200
@@ -283,6 +283,10 @@ 
         tr.hookargs['phases_moved'] = '1'
 
     def advanceboundary(self, repo, tr, targetphase, nodes):
+        """Set all 'nodes' to phase 'targetphase'
+
+        Nodes with a phase lower than 'targetphase' are not affected.
+        """
         # Be careful to preserve shallow-copied values: do not update
         # phaseroots values, replace them.
 
@@ -294,9 +298,12 @@ 
                      if self.phase(repo, repo[n].rev()) >= phase]
             if not nodes:
                 break # no roots to move anymore
+
             olds = self.phaseroots[phase]
+            affected = repo.revs('%ln::%ln', olds, nodes)
+
             roots = set(ctx.node() for ctx in repo.set(
-                    'roots((%ln::) - (%ln::%ln))', olds, olds, nodes))
+                    'roots((%ln::) - %ld)', olds, affected))
             if olds != roots:
                 self._updateroots(phase, roots, tr)
                 # some roots may need to be declared for lower phases