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

Laurent Charignon lcharignon at fb.com
Mon Nov 16 19:18:04 CST 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1447722936 28800
#      Mon Nov 16 17:15:36 2015 -0800
# Node ID e4592fb0c10a36eca9dc899bedfd963694edfd33
# Parent  3311e2750b7fdaac9c33089d0fab47b9718fd381
convert: use repo._bookmarks.recordchange instead of repo._bookmarks.write

Before this patch, convert was using repo._bookmarks.write, a deprecated API
for saving bookmarks.
This patch changes the use of repo._bookmarks.write to
repo._bookmarks.recordchange.

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -23,6 +23,7 @@
 from mercurial.node import bin, hex, nullid
 from mercurial import hg, util, context, bookmarks, error, scmutil, exchange
 from mercurial import phases
+from mercurial import lock as lockmod
 from mercurial import merge as mergemod
 
 from common import NoRepo, commit, converter_source, converter_sink, mapfile
@@ -410,12 +411,19 @@
     def putbookmarks(self, updatedbookmark):
         if not len(updatedbookmark):
             return
-        if True:
+        wlock = lock = tr = None
+        try:
+            wlock = self.repo.wlock()
+            lock = self.repo.lock()
+            tr = self.repo.transaction('bookmark')
             self.ui.status(_("updating bookmarks\n"))
             destmarks = self.repo._bookmarks
             for bookmark in updatedbookmark:
                 destmarks[bookmark] = bin(updatedbookmark[bookmark])
-            destmarks.write()
+            destmarks.recordchange(tr)
+            tr.close()
+        finally:
+            lockmod.release(lock, wlock, tr)
 
     def hascommitfrommap(self, rev):
         # the exact semantics of clonebranches is unclear so we can't say no


More information about the Mercurial-devel mailing list