changeset 27870:ed9950ba091e

with: use context manager for transaction in consumev1
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:49 -0800
parents 76ecf0227ea5
children f1c316fd91f9
files mercurial/streamclone.py
diffstat 1 files changed, 1 insertions(+), 5 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
@@ -297,8 +297,7 @@
         repo.ui.progress(_('clone'), 0, total=bytecount)
         start = time.time()
 
-        tr = repo.transaction('clone')
-        try:
+        with repo.transaction('clone'):
             for i in xrange(filecount):
                 # XXX doesn't support '\n' or '\r' in filenames
                 l = fp.readline()
@@ -318,9 +317,6 @@
                         repo.ui.progress(_('clone'), handled_bytes,
                                          total=bytecount)
                         ofp.write(chunk)
-            tr.close()
-        finally:
-            tr.release()
 
         # Writing straight to files circumvented the inmemory caches
         repo.invalidate()