with: use context manager in amend
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:50 -0800
changeset 27868 d1a55366d825
parent 27867 7ced54ebf972
child 27869 76ecf0227ea5
with: use context manager in amend
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Fri Jan 15 13:14:50 2016 -0800
+++ b/mercurial/cmdutil.py	Fri Jan 15 13:14:50 2016 -0800
@@ -2512,8 +2512,7 @@
     try:
         wlock = repo.wlock()
         lock = repo.lock()
-        tr = repo.transaction('amend')
-        try:
+        with repo.transaction('amend') as tr:
             # See if we got a message from -m or -l, if not, open the editor
             # with the message of the changeset to amend
             message = logmessage(ui, opts)
@@ -2685,9 +2684,6 @@
                         obs.append((ctx, ()))
 
                     obsolete.createmarkers(repo, obs)
-            tr.close()
-        finally:
-            tr.release()
         if not createmarkers and newid != old.node():
             # Strip the intermediate commit (if there was one) and the amended
             # commit