streamclone: use read()
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 02 Jan 2016 15:14:55 -0800
changeset 27632 9fea6b38a8da
parent 27631 c18292a6ff54
child 27633 37d7cf569cf3
streamclone: use read() We have a convenience API for reading the full contents of a file. Use it.
mercurial/streamclone.py
--- a/mercurial/streamclone.py	Wed Dec 30 16:21:57 2015 -0700
+++ b/mercurial/streamclone.py	Sat Jan 02 15:14:55 2016 -0800
@@ -212,12 +212,7 @@
                 # partially encode name over the wire for backwards compat
                 yield '%s\0%d\n' % (store.encodedir(name), size)
                 if size <= 65536:
-                    fp = svfs(name)
-                    try:
-                        data = fp.read(size)
-                    finally:
-                        fp.close()
-                    yield data
+                    yield svfs.read(name)
                 else:
                     for chunk in util.filechunkiter(svfs(name), limit=size):
                         yield chunk