Patchwork D1839: bookmarks: use context managers for lock and transaction in update()

login
register
mail settings
Submitter phabricator
Date Jan. 10, 2018, 7:22 p.m.
Message ID <differential-rev-PHID-DREV-bxgc262pep3wqx2mqlwx-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26643/
State Superseded
Headers show

Comments

phabricator - Jan. 10, 2018, 7:22 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1839

AFFECTED FILES
  mercurial/bookmarks.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -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):