changeset 27869:76ecf0227ea5

with: use context manager in _histedit
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:49 -0800
parents d1a55366d825
children ed9950ba091e
files hgext/histedit.py
diffstat 1 files changed, 1 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Fri Jan 15 13:14:50 2016 -0800
+++ b/hgext/histedit.py	Fri Jan 15 13:14:49 2016 -0800
@@ -1066,17 +1066,13 @@
                 backupfile = repo.join(state.backupfile)
                 f = hg.openpath(ui, backupfile)
                 gen = exchange.readbundle(ui, f, backupfile)
-                tr = repo.transaction('histedit.abort')
-                try:
+                with repo.transaction('histedit.abort') as tr:
                     if not isinstance(gen, bundle2.unbundle20):
                         gen.apply(repo, 'histedit', 'bundle:' + backupfile)
                     if isinstance(gen, bundle2.unbundle20):
                         bundle2.applybundle(repo, gen, tr,
                                             source='histedit',
                                             url='bundle:' + backupfile)
-                    tr.close()
-                finally:
-                    tr.release()
 
                 os.remove(backupfile)