bookmarks: use context managers for lock and transaction in update()
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 10 Jan 2018 10:47:13 -0800
changeset 35576 b9a0de08110e
parent 35575 dda3cae3c9c5
child 35577 ac7ee75ee664
bookmarks: use context managers for lock and transaction in update() Differential Revision: https://phab.mercurial-scm.org/D1839
mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Wed Jan 10 10:44:21 2018 -0800
+++ b/mercurial/bookmarks.py	Wed Jan 10 10:47:13 2018 -0800
@@ -392,14 +392,8 @@
         bmchanges.append((bm, None))
 
     if bmchanges:
-        lock = tr = None
-        try:
-            lock = repo.lock()
-            tr = repo.transaction('bookmark')
+        with repo.lock(), repo.transaction('bookmark') as tr:
             marks.applychanges(repo, tr, bmchanges)
-            tr.close()
-        finally:
-            lockmod.release(tr, lock)
     return bool(bmchanges)
 
 def listbinbookmarks(repo):