changeset 27859:f55a5ace8e69

with: use context manager in streamclone consumev1
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:49 -0800
parents 7575c048482d
children 0da102e4f203
files mercurial/streamclone.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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.