changeset 35574:09285733ad71

obsolete: use context manager for transaction in pushmarker() Differential Revision: https://phab.mercurial-scm.org/D1837
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 10 Jan 2018 10:33:11 -0800
parents 5574629d5d45
children dda3cae3c9c5
files mercurial/obsolete.py
diffstat 1 files changed, 4 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Wed Jan 10 10:32:16 2018 -0800
+++ b/mercurial/obsolete.py	Wed Jan 10 10:33:11 2018 -0800
@@ -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):