changeset 958:8140bbc2fdc2

bookmarks: use bookmarks.recordchange instead of bookmarks.write if available bookmarks.write is deprecated and it was showing warning messages in test-hg-branch.t with the latest test runner from core mercurial. Tested with both hg 2.8 and hg tip.
author Laurent Charignon <lcharignon@fb.com>
date Wed, 30 Dec 2015 10:27:24 -0800
parents e7316a108780
children f2391790aaf6
files hggit/git_handler.py
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -21,6 +21,7 @@
 from mercurial import commands
 from mercurial import context, util as hgutil
 from mercurial import url
+from mercurial import lock as lockmod
 
 import _ssh
 import git2hg
@@ -1308,11 +1309,19 @@
                         bms[head + suffix] = hgsha
 
             if heads:
-                wlock = self.repo.wlock()
+                tr = lock = wlock = None
                 try:
-                    bms.write()
+                    wlock = self.repo.wlock()
+                    lock = self.repo.lock()
+                    tr = self.repo.transaction('git_handler')
+                    if hgutil.safehasattr(bms, 'recordchange'):
+                        # recordchange was added in mercurial 3.2
+                        bms.recordchange(tr)
+                    else:
+                        bms.write()
+                    tr.close()
                 finally:
-                    wlock.release()
+                    lockmod.release(tr, lock, wlock)
 
         except AttributeError:
             self.ui.warn(_('creating bookmarks failed, do you have'