changeset 27850:49cfddbf54ba

with: use context manager in maybeperformlegacystreamclone
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:49 -0800
parents 900d36a3e4dd
children 4133a306606c
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
@@ -137,8 +137,7 @@
         raise error.ResponseError(
             _('unexpected response from remote server:'), l)
 
-    lock = repo.lock()
-    try:
+    with repo.lock():
         consumev1(repo, fp, filecount, bytecount)
 
         # new requirements = old non-format requirements +
@@ -153,8 +152,6 @@
             branchmap.replacecache(repo, rbranchmap)
 
         repo.invalidate()
-    finally:
-        lock.release()
 
 def allowservergeneration(ui):
     """Whether streaming clones are allowed from the server."""