with: use context manager in unbundle
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:49 -0800
changeset 27855 5b675a5665ef
parent 27854 55394c6fe74e
child 27856 2b3a21052be9
with: use context manager in unbundle
mercurial/commands.py
--- a/mercurial/commands.py	Fri Jan 15 13:14:49 2016 -0800
+++ b/mercurial/commands.py	Fri Jan 15 13:14:49 2016 -0800
@@ -6831,8 +6831,7 @@
     """
     fnames = (fname1,) + fnames
 
-    lock = repo.lock()
-    try:
+    with repo.lock():
         for fname in fnames:
             f = hg.openpath(ui, fname)
             gen = exchange.readbundle(ui, f, fname)
@@ -6861,8 +6860,6 @@
                         hint=_('use "hg debugapplystreamclonebundle"'))
             else:
                 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
-    finally:
-        lock.release()
 
     return postincoming(ui, repo, modheads, opts.get('update'), None)