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

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

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1837?vs=4757&id=4767

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

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,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):