with: use context manager in streamclone generatev1
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:50 -0800
changeset 27845 7417e1c10253
parent 27844 469b86c49503
child 27846 63821023ea79
with: use context manager in streamclone generatev1
mercurial/streamclone.py
--- a/mercurial/streamclone.py	Fri Jan 15 13:14:50 2016 -0800
+++ b/mercurial/streamclone.py	Fri Jan 15 13:14:50 2016 -0800
@@ -186,15 +186,12 @@
     entries = []
     total_bytes = 0
     # Get consistent snapshot of repo, lock during scan.
-    lock = repo.lock()
-    try:
+    with repo.lock():
         repo.ui.debug('scanning\n')
         for name, ename, size in _walkstreamfiles(repo):
             if size:
                 entries.append((name, size))
                 total_bytes += size
-    finally:
-            lock.release()
 
     repo.ui.debug('%d files, %d bytes to transfer\n' %
                   (len(entries), total_bytes))