# HG changeset patch # User Gregory Szorc # Date 2016-01-15 05:27:53 # Node ID acfe40eb8cb57f2ec2d778d7ba318d789d4c6adc # Parent 4f4b80b3f2bfadbc9a500d9612ecdee537224be6 commands: use context manager for opened bundle file diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2012,8 +2012,7 @@ def debugbuilddag(ui, repo, text=None, norepo=True) def debugbundle(ui, bundlepath, all=None, **opts): """lists the contents of a bundle""" - f = hg.openpath(ui, bundlepath) - try: + with hg.openpath(ui, bundlepath) as f: gen = exchange.readbundle(ui, f, bundlepath) if isinstance(gen, bundle2.unbundle20): return _debugbundle2(ui, gen, all=all, **opts) @@ -2060,8 +2059,6 @@ def debugbundle(ui, bundlepath, all=None node = chunkdata['node'] ui.write("%s\n" % hex(node)) chain = node - finally: - f.close() def _debugbundle2(ui, gen, **opts): """lists the contents of a bundle2"""