# HG changeset patch # User Pierre-Yves David # Date 2014-08-06 08:54:19 # Node ID 616a455b02caf8cdbe34faa0f9283c0560a0e9f9 # Parent d34058dd3246d739dcaed569da2b5afc6d2eebe3 phase: add a transaction argument to advanceboundary We now pass a transaction option to this phase movement function. The object is 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 in 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/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -932,7 +932,7 @@ class queue(object): if oldqbase.phase() > tphase and oldqbase.p1().phase() <= tphase: tr = repo.transaction('qfinish') try: - phases.advanceboundary(repo, tphase, qfinished) + phases.advanceboundary(repo, tr, tphase, qfinished) tr.close() finally: tr.release() diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -700,12 +700,12 @@ def addchangegroup(repo, source, srctype # 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) else: # 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 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4583,7 +4583,7 @@ def phase(ui, repo, *revs, **opts): 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) tr.close() diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -577,7 +577,7 @@ def _localphasemove(pushop, nodes, phase if pushop.locallocked: tr = pushop.repo.transaction('push-phase-sync') try: - phases.advanceboundary(pushop.repo, phase, nodes) + phases.advanceboundary(pushop.repo, tr, phase, nodes) tr.close() finally: tr.release() @@ -840,12 +840,14 @@ def _pullapplyphases(pullop, remotephase # 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 diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -208,7 +208,7 @@ class phasecache(object): 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. @@ -278,7 +278,7 @@ class phasecache(object): # (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 @@ -286,7 +286,7 @@ def advanceboundary(repo, targetphase, n Simplify boundary to contains phase roots only.""" phcache = repo._phasecache.copy() - phcache.advanceboundary(repo, targetphase, nodes) + phcache.advanceboundary(repo, tr, targetphase, nodes) repo._phasecache.replace(phcache) def retractboundary(repo, targetphase, nodes): @@ -339,7 +339,7 @@ def pushphase(repo, nhex, oldphasestr, n 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)]) tr.close() return 1 elif currentphase == newphase: