with: use context manager in streamclone consumev1
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:49 -0800
changeset 27859 f55a5ace8e69
parent 27858 7575c048482d
child 27860 0da102e4f203
with: use context manager in streamclone consumev1
mercurial/streamclone.py
--- a/mercurial/streamclone.py	Fri Jan 15 13:14:49 2016 -0800
+++ b/mercurial/streamclone.py	Fri Jan 15 13:14:49 2016 -0800
@@ -290,8 +290,7 @@
     Like "streamout," the status line added by the wire protocol is not handled
     by this function.
     """
-    lock = repo.lock()
-    try:
+    with repo.lock():
         repo.ui.status(_('%d files to transfer, %s of data\n') %
                        (filecount, util.bytecount(bytecount)))
         handled_bytes = 0
@@ -333,8 +332,6 @@
         repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
                        (util.bytecount(bytecount), elapsed,
                         util.bytecount(bytecount / elapsed)))
-    finally:
-        lock.release()
 
 def applybundlev1(repo, fp):
     """Apply the content from a stream clone bundle version 1.