Patchwork D1836: obsolete: use context manager for lock in pushmarker()

login
register
mail settings
Submitter phabricator
Date Jan. 10, 2018, 7:22 p.m.
Message ID <differential-rev-PHID-DREV-2nkby5pvzf63hv5fxsuw-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26641/
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/D1836

AFFECTED FILES
  mercurial/obsolete.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -838,18 +838,15 @@ 
         repo.ui.warn(_('unexpected old value for %r') % key)
         return False
     data = util.b85decode(new)
-    lock = repo.lock()
-    try:
+    with repo.lock():
         tr = repo.transaction('pushkey: obsolete markers')
         try:
             repo.obsstore.mergemarkers(tr, data)
             repo.invalidatevolatilesets()
             tr.close()
             return True
         finally:
             tr.release()
-    finally:
-        lock.release()
 
 # keep compatibility for the 4.3 cycle
 def allprecursors(obsstore, nodes, ignoreflags=0):