with: use context manager in maybeperformlegacystreamclone
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:49 -0800
changeset 27850 49cfddbf54ba
parent 27849 900d36a3e4dd
child 27851 4133a306606c
with: use context manager in maybeperformlegacystreamclone
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
@@ -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."""