D3671: advanceboundary: add dryrun parameter

khanchi97 (Sushil khanchi) phabricator at mercurial-scm.org
Fri Jun 1 08:30:15 EDT 2018


khanchi97 updated this revision to Diff 8950.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3671?vs=8949&id=8950

REVISION DETAIL
  https://phab.mercurial-scm.org/D3671

AFFECTED FILES
  mercurial/phases.py

CHANGE DETAILS

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -352,10 +352,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.
@@ -366,6 +370,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
@@ -377,6 +382,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)
@@ -387,10 +395,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]
@@ -478,16 +488,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



To: khanchi97, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel


More information about the Mercurial-devel mailing list