Patchwork [1,of,5] mq: wrap qfinish phase movement in a transaction

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 6, 2014, 8:25 a.m.
Message ID <7ff215a4cf1c0d452642.1407313518@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5289/
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 1407311331 25200
#      Wed Aug 06 00:48:51 2014 -0700
# Node ID 7ff215a4cf1c0d452642fa2b820ed84c76b3dc9f
# Parent  8d99c107b0414f68f5c0add2f642b3d576fedcab
mq: wrap qfinish 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/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -928,11 +928,16 @@  class queue(object):
         if qfinished and repo.ui.configbool('mq', 'secret', False):
             # only use this logic when the secret option is added
             oldqbase = repo[qfinished[0]]
             tphase = repo.ui.config('phases', 'new-commit', phases.draft)
             if oldqbase.phase() > tphase and oldqbase.p1().phase() <= tphase:
-                phases.advanceboundary(repo, tphase, qfinished)
+                tr = repo.transaction('qfinish')
+                try:
+                    phases.advanceboundary(repo, tphase, qfinished)
+                    tr.close()
+                finally:
+                    tr.release()
 
     def delete(self, repo, patches, opts):
         if not patches and not opts.get('rev'):
             raise util.Abort(_('qdelete requires at least one revision or '
                                'patch name'))