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

login
register
mail settings
Submitter phabricator
Date Jan. 10, 2018, 11:02 p.m.
Message ID <3e6843e1099ae28407dca883c1f9438f@localhost.localdomain>
Download mbox | patch
Permalink /patch/26651/
State Not Applicable
Headers show

Comments

phabricator - Jan. 10, 2018, 11:02 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb9a0de08110e: bookmarks: use context managers for lock and transaction in update() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1839?vs=4759&id=4769

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

AFFECTED FILES
  mercurial/bookmarks.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, durin42
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):