Patchwork D1837: obsolete: use context manager for transaction in pushmarker()

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

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,15 +838,10 @@ 
         repo.ui.warn(_('unexpected old value for %r') % key)
         return False
     data = util.b85decode(new)
-    with repo.lock():
-        tr = repo.transaction('pushkey: obsolete markers')
-        try:
-            repo.obsstore.mergemarkers(tr, data)
-            repo.invalidatevolatilesets()
-            tr.close()
-            return True
-        finally:
-            tr.release()
+    with repo.lock(), repo.transaction('pushkey: obsolete markers') as tr:
+        repo.obsstore.mergemarkers(tr, data)
+        repo.invalidatevolatilesets()
+        return True
 
 # keep compatibility for the 4.3 cycle
 def allprecursors(obsstore, nodes, ignoreflags=0):