changeset 35576:b9a0de08110e

bookmarks: use context managers for lock and transaction in update() Differential Revision: https://phab.mercurial-scm.org/D1839
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 10 Jan 2018 10:47:13 -0800
parents dda3cae3c9c5
children ac7ee75ee664
files mercurial/bookmarks.py
diffstat 1 files changed, 1 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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):