[PATCH 2 of 2 V2] mq: use repo._bookmarks.write instead of repo._bookmarks.recordchange

Laurent Charignon lcharignon at fb.com
Tue Nov 17 15:13:54 CST 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1447794753 28800
#      Tue Nov 17 13:12:33 2015 -0800
# Node ID fba21cf1b66f163c502d188768190029fae0d382
# Parent  e48f26347c51a1d0e2d6af8db6c956ce7286a406
mq: use repo._bookmarks.write instead of repo._bookmarks.recordchange

Before this patch, mq was using repo._bookmarks.write.
This patch replaces this code with the recommended way of saving bookmarks
changes: repo._bookmarks.recordchange.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -68,6 +68,7 @@
 from mercurial import commands, cmdutil, hg, scmutil, util, revset
 from mercurial import extensions, error, phases
 from mercurial import patch as patchmod
+from mercurial import lock as lockmod
 from mercurial import localrepo
 from mercurial import subrepo
 import os, re, errno, shutil
@@ -1790,7 +1791,10 @@
 
                 # Ensure we create a new changeset in the same phase than
                 # the old one.
-                if True:
+                lock = tr = None
+                try:
+                    lock = repo.lock()
+                    tr = repo.transaction('mq')
                     n = newcommit(repo, oldphase, message, user, ph.date,
                               match=match, force=True, editor=editor)
                     # only write patch after a successful commit
@@ -1809,9 +1813,12 @@
                     marks = repo._bookmarks
                     for bm in bmlist:
                         marks[bm] = n
-                    marks.write()
+                    marks.recordchange(tr)
+                    tr.close()
 
                     self.applied.append(statusentry(n, patchfn))
+                finally:
+                    lockmod.release(lock, tr)
             except: # re-raises
                 ctx = repo[cparents[0]]
                 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
diff --git a/tests/test-mq-qrefresh-replace-log-message.t b/tests/test-mq-qrefresh-replace-log-message.t
--- a/tests/test-mq-qrefresh-replace-log-message.t
+++ b/tests/test-mq-qrefresh-replace-log-message.t
@@ -185,9 +185,9 @@
   HG: branch 'default'
   HG: added file2
   ====
+  note: commit message saved in .hg/last-message.txt
   transaction abort!
   rollback completed
-  note: commit message saved in .hg/last-message.txt
   qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
   abort: pretxncommit.unexpectedabort hook exited with status 1
   [255]
@@ -228,9 +228,9 @@
   0:25e397dabed2
   A file2
   ====
+  note: commit message saved in .hg/last-message.txt
   transaction abort!
   rollback completed
-  note: commit message saved in .hg/last-message.txt
   qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
   abort: pretxncommit.unexpectedabort hook exited with status 1
   [255]


More information about the Mercurial-devel mailing list