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

login
register
mail settings
Submitter phabricator
Date Jan. 10, 2018, 11:02 p.m.
Message ID <c1b96aceeec5dd27e817b31c79eab3b6@localhost.localdomain>
Download mbox | patch
Permalink /patch/26649/
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 rHG5574629d5d45: obsolete: use context manager for lock in pushmarker() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1836?vs=4756&id=4766

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

AFFECTED FILES
  mercurial/obsolete.py

CHANGE DETAILS




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