mercurial/phases.py
changeset 38218 36ba5dba372d
parent 38158 4e790f0966fc
child 38682 88efb7d6bcb6
--- a/mercurial/phases.py	Wed May 30 17:37:17 2018 +0530
+++ b/mercurial/phases.py	Wed May 30 14:20:09 2018 +0530
@@ -354,10 +354,14 @@
                 _trackphasechange(phasetracking, rev, None, revphase)
         repo.invalidatevolatilesets()
 
-    def advanceboundary(self, repo, tr, targetphase, nodes):
+    def advanceboundary(self, repo, tr, targetphase, nodes, dryrun=None):
         """Set all 'nodes' to phase 'targetphase'
 
         Nodes with a phase lower than 'targetphase' are not affected.
+
+        If dryrun is True, no actions will be performed
+
+        Returns a set of revs whose phase is changed or should be changed
         """
         # Be careful to preserve shallow-copied values: do not update
         # phaseroots values, replace them.
@@ -368,6 +372,7 @@
 
         repo = repo.unfiltered()
 
+        changes = set() # set of revisions to be changed
         delroots = [] # set of root deleted by this path
         for phase in xrange(targetphase + 1, len(allphases)):
             # filter nodes that are not in a compatible phase already
@@ -379,6 +384,9 @@
             olds = self.phaseroots[phase]
 
             affected = repo.revs('%ln::%ln', olds, nodes)
+            changes.update(affected)
+            if dryrun:
+                continue
             for r in affected:
                 _trackphasechange(phasetracking, r, self.phase(repo, r),
                                   targetphase)
@@ -389,10 +397,12 @@
                 self._updateroots(phase, roots, tr)
                 # some roots may need to be declared for lower phases
                 delroots.extend(olds - roots)
-        # declare deleted root in the target phase
-        if targetphase != 0:
-            self._retractboundary(repo, tr, targetphase, delroots)
-        repo.invalidatevolatilesets()
+        if not dryrun:
+            # declare deleted root in the target phase
+            if targetphase != 0:
+                self._retractboundary(repo, tr, targetphase, delroots)
+            repo.invalidatevolatilesets()
+        return changes
 
     def retractboundary(self, repo, tr, targetphase, nodes):
         oldroots = self.phaseroots[:targetphase + 1]
@@ -480,16 +490,24 @@
         # (see branchmap one)
         self.invalidate()
 
-def advanceboundary(repo, tr, targetphase, nodes):
+def advanceboundary(repo, tr, targetphase, nodes, dryrun=None):
     """Add nodes to a phase changing other nodes phases if necessary.
 
     This function move boundary *forward* this means that all nodes
     are set in the target phase or kept in a *lower* phase.
 
-    Simplify boundary to contains phase roots only."""
+    Simplify boundary to contains phase roots only.
+
+    If dryrun is True, no actions will be performed
+
+    Returns a set of revs whose phase is changed or should be changed
+    """
     phcache = repo._phasecache.copy()
-    phcache.advanceboundary(repo, tr, targetphase, nodes)
-    repo._phasecache.replace(phcache)
+    changes = phcache.advanceboundary(repo, tr, targetphase, nodes,
+                                      dryrun=dryrun)
+    if not dryrun:
+        repo._phasecache.replace(phcache)
+    return changes
 
 def retractboundary(repo, tr, targetphase, nodes):
     """Set nodes back to a phase changing other nodes phases if