Patchwork [3,of,5] phase: wrap `hg phases` phase movement in a transaction

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 6, 2014, 8:25 a.m.
Message ID <6724ab8cf150f9967ba2.1407313520@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5291/
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 1407311453 25200
#      Wed Aug 06 00:50:53 2014 -0700
# Node ID 6724ab8cf150f9967ba20b9a6d40b56c2f0aafce
# Parent  22e086fa7008c0dedf9b41adae7dc9f112730e01
phase: wrap `hg phases` 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/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4572,21 +4572,26 @@  def phase(ui, repo, *revs, **opts):
         # display
         for r in revs:
             ctx = repo[r]
             ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
     else:
+        tr = None
         lock = repo.lock()
         try:
+            tr = repo.transaction("phase")
             # 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)
             if opts['force']:
                 phases.retractboundary(repo, targetphase, nodes)
+            tr.close()
         finally:
+            if tr is not None:
+                tr.release()
             lock.release()
         # moving revision from public to draft may hide them
         # We have to check result on an unfiltered repository
         unfi = repo.unfiltered()
         newdata = repo._phasecache.getphaserevs(unfi)