Patchwork [2,of,3] phase: add a transaction argument to advanceboundary

mail settings
Submitter Pierre-Yves David
Date Aug. 7, 2014, 2:19 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/5307/
State Accepted
Commit 616a455b02caf8cdbe34faa0f9283c0560a0e9f9
Headers show


Pierre-Yves David - Aug. 7, 2014, 2:19 a.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1407315259 25200
#      Wed Aug 06 01:54:19 2014 -0700
# Node ID bea88c30e77bd66a181580a1a9738620d5eb14ab
# Parent  868752444f3b8a350bd7a64ecd55d239335578c2
phase: add a transaction argument to advanceboundary

We now pass a transaction option to this phase movement function. The object
currently not used by the function, but it will be in the future.

All call sites have been updated. Most call sites were already enclosed into a
transaction for a long time. The handful of others have been recently
updated in previous commit.

The retractboundary function remains to be upgraded.


diff --git a/hgext/ b/hgext/
--- a/hgext/
+++ b/hgext/
@@ -930,11 +930,11 @@  class queue(object):
             oldqbase = repo[qfinished[0]]
             tphase = repo.ui.config('phases', 'new-commit', phases.draft)
             if oldqbase.phase() > tphase and oldqbase.p1().phase() <= tphase:
                 tr = repo.transaction('qfinish')
-                    phases.advanceboundary(repo, tphase, qfinished)
+                    phases.advanceboundary(repo, tr, tphase, qfinished)
     def delete(self, repo, patches, opts):
diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -698,16 +698,16 @@  def addchangegroup(repo, source, srctype
             # exists locally as secret
             # We should not use added here but the list of all change in
             # the bundle
             if publishing:
-                phases.advanceboundary(repo, phases.public, srccontent)
+                phases.advanceboundary(repo, tr, phases.public, srccontent)
                 # Those changesets have been pushed from the outside, their
                 # phases are going to be pushed alongside. Therefor
                 # `targetphase` is ignored.
-                phases.advanceboundary(repo, phases.draft, srccontent)
+                phases.advanceboundary(repo, tr, phases.draft, srccontent)
                 phases.retractboundary(repo, phases.draft, added)
         elif srctype != 'strip':
             # publishing only alter behavior during push
             # strip should not touch boundary at all
diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -4581,11 +4581,11 @@  def phase(ui, repo, *revs, **opts):
             # set phase
             if not revs:
                 raise util.Abort(_('empty revision set'))
             nodes = [repo[r].node() for r in revs]
             olddata = repo._phasecache.getphaserevs(repo)[:]
-            phases.advanceboundary(repo, targetphase, nodes)
+            phases.advanceboundary(repo, tr, targetphase, nodes)
             if opts['force']:
                 phases.retractboundary(repo, targetphase, nodes)
             if tr is not None:
diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -577,11 +577,11 @@  def _pushsyncphase(pushop):
 def _localphasemove(pushop, nodes, phase=phases.public):
     """move <nodes> to <phase> in the local source repo"""
     if pushop.locallocked:
         tr = pushop.repo.transaction('push-phase-sync')
-            phases.advanceboundary(pushop.repo, phase, nodes)
+            phases.advanceboundary(pushop.repo, tr, phase, nodes)
         # repo is not locked, do not change any phases!
@@ -840,16 +840,18 @@  def _pullapplyphases(pullop, remotephase
     draft = phases.draft
     # exclude changesets already public locally and update the others
     pheads = [pn for pn in pheads if phase(unfi, rev(pn)) > public]
     if pheads:
-        phases.advanceboundary(pullop.repo, public, pheads)
+        tr = pullop.gettransaction()
+        phases.advanceboundary(pullop.repo, tr, public, pheads)
     # exclude changesets already draft locally and update the others
     dheads = [pn for pn in dheads if phase(unfi, rev(pn)) > draft]
     if dheads:
-        phases.advanceboundary(pullop.repo, draft, dheads)
+        tr = pullop.gettransaction()
+        phases.advanceboundary(pullop.repo, tr, draft, dheads)
 def _pullobsolete(pullop):
     """utility function to pull obsolete markers from a remote
     The `gettransaction` is function that return the pull transaction, creating
diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -206,11 +206,11 @@  class phasecache(object):
     def _updateroots(self, phase, newroots):
         self.phaseroots[phase] = newroots
         self._phaserevs = None
         self.dirty = True
-    def advanceboundary(self, repo, targetphase, nodes):
+    def advanceboundary(self, repo, tr, targetphase, nodes):
         # Be careful to preserve shallow-copied values: do not update
         # phaseroots values, replace them.
         repo = repo.unfiltered()
         delroots = [] # set of root deleted by this path
@@ -276,19 +276,19 @@  class phasecache(object):
         # anyway. If this change we should consider adding a dedicated
         # "destroyed" function to phasecache or a proper cache key mechanism
         # (see branchmap one)
         self._phaserevs = None
-def advanceboundary(repo, targetphase, nodes):
+def advanceboundary(repo, tr, targetphase, nodes):
     """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."""
     phcache = repo._phasecache.copy()
-    phcache.advanceboundary(repo, targetphase, nodes)
+    phcache.advanceboundary(repo, tr, targetphase, nodes)
 def retractboundary(repo, targetphase, nodes):
     """Set nodes back to a phase changing other nodes phases if
@@ -337,11 +337,11 @@  def pushphase(repo, nhex, oldphasestr, n
         currentphase = repo[nhex].phase()
         newphase = abs(int(newphasestr)) # let's avoid negative index surprise
         oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
         if currentphase == oldphase and newphase < oldphase:
             tr = repo.transaction('pushkey-phase')
-            advanceboundary(repo, newphase, [bin(nhex)])
+            advanceboundary(repo, tr, newphase, [bin(nhex)])
             return 1
         elif currentphase == newphase:
             # raced, but got correct result
             return 1