Patchwork [4,of,5] push: wrap local phase movement in a transaction

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 6, 2014, 8:25 a.m.
Message ID <5140e19e070401f1c2ff.1407313521@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5292/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 6, 2014, 8:25 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1407311655 25200
#      Wed Aug 06 00:54:15 2014 -0700
# Node ID 5140e19e070401f1c2ff560385185f6cb17e7b6d
# Parent  6724ab8cf150f9967ba20b9a6d40b56c2f0aafce
push: wrap local phase movement in a transaction

Phases are not yet inside the transaction, but we need to prepare for it. So we
wrap the phase movement inside a transaction.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -575,11 +575,16 @@  def _pushsyncphase(pushop):
                                    % newremotehead)
 
 def _localphasemove(pushop, nodes, phase=phases.public):
     """move <nodes> to <phase> in the local source repo"""
     if pushop.locallocked:
-        phases.advanceboundary(pushop.repo, phase, nodes)
+        tr = pushop.repo.transaction('push-phase-sync')
+        try:
+            phases.advanceboundary(pushop.repo, phase, nodes)
+            tr.close()
+        finally:
+            tr.release()
     else:
         # repo is not locked, do not change any phases!
         # Informs the user that phases should have been moved when
         # applicable.
         actualmoves = [n for n in nodes if phase < pushop.repo[n].phase()]