Patchwork [5,of,5] pushkey: wrap pushkey phase movement in a transaction

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 6, 2014, 8:25 a.m.
Message ID <9d6c92dbfcf46b4a8d7c.1407313522@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5293/
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 1407311698 25200
#      Wed Aug 06 00:54:58 2014 -0700
# Node ID 9d6c92dbfcf46b4a8d7c66b5b882d0a0e087407f
# Parent  5140e19e070401f1c2ff560385185f6cb17e7b6d
pushkey: wrap pushkey 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.
Matt Mackall - Aug. 6, 2014, 5:10 p.m.
On Wed, 2014-08-06 at 01:25 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1407311698 25200
> #      Wed Aug 06 00:54:58 2014 -0700
> # Node ID 9d6c92dbfcf46b4a8d7c66b5b882d0a0e087407f
> # Parent  5140e19e070401f1c2ff560385185f6cb17e7b6d
> pushkey: wrap pushkey phase movement in a transaction

These are queued for default, thanks.

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -329,24 +329,29 @@  def listphases(repo):
     return keys
 
 def pushphase(repo, nhex, oldphasestr, newphasestr):
     """List phases root for serialization over pushkey"""
     repo = repo.unfiltered()
+    tr = None
     lock = repo.lock()
     try:
         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)])
+            tr.close()
             return 1
         elif currentphase == newphase:
             # raced, but got correct result
             return 1
         else:
             return 0
     finally:
+        if tr:
+            tr.release()
         lock.release()
 
 def analyzeremotephases(repo, subset, roots):
     """Compute phases heads and root in a subset of node from root dict