changeset 26974:4b5dc0d9e899

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.
author Laurent Charignon <lcharignon@fb.com>
date Mon, 16 Nov 2015 17:15:36 -0800
parents fdd63acf3215
children 6618dfd3ea1c
files hgext/convert/hg.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/hg.py	Mon Nov 16 17:14:15 2015 -0800
+++ b/hgext/convert/hg.py	Mon Nov 16 17:15:36 2015 -0800
@@ -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