inhibit: fix devel warning
authorLaurent Charignon <lcharignon@fb.com>
Wed, 29 Apr 2015 13:01:23 -0700
changeset 1297 51ec3610968c
parent 1295 1ac05eef72ca
child 1298 b8c01464323c
inhibit: fix devel warning _inhibitmarkers was taking a transaction without the proper lock. Adding the lock removes the warnings.
hgext/inhibit.py
--- a/hgext/inhibit.py	Wed Apr 29 14:23:09 2015 -0700
+++ b/hgext/inhibit.py	Wed Apr 29 13:01:23 2015 -0700
@@ -29,6 +29,7 @@
 from mercurial import revset
 from mercurial import error
 from mercurial import commands
+from mercurial import lock as lockmod
 from mercurial import bookmarks
 from mercurial.i18n import _
 
@@ -126,14 +127,16 @@
     """
     newinhibit = repo.set('::%ln and obsolete()', nodes)
     if newinhibit:
-        tr = repo.transaction('obsinhibit')
+        lock = tr = None
         try:
+            lock = repo.lock()
+            tr = repo.transaction('obsinhibit')
             repo._obsinhibit.update(c.node() for c in newinhibit)
             _schedulewrite(tr, _filterpublic(repo, repo._obsinhibit))
             repo.invalidatevolatilesets()
             tr.close()
         finally:
-            tr.release()
+            lockmod.release(tr, lock)
 
 def _deinhibitmarkers(repo, nodes):
     """lift obsolescence inhibition on a set of nodes