changeset 27845:7417e1c10253

with: use context manager in streamclone generatev1
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:50 -0800
parents 469b86c49503
children 63821023ea79
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: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))