# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-15 21:14:49 # Node ID 76ecf0227ea53b74b05e7bec1e18693dca8c3d07 # Parent d1a55366d825aceb661fbc857c5c009b240210d5 with: use context manager in _histedit diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -1066,17 +1066,13 @@ def _histedit(ui, repo, state, *freeargs 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)