[PATCH 1 of 5 V2] streamclone: use read()
Gregory Szorc
gregory.szorc at gmail.com
Sun Jan 3 00:45:29 UTC 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1451776495 28800
# Sat Jan 02 15:14:55 2016 -0800
# Node ID 8a33bbee1ed445f61c825a789d7c5b9d93295eef
# Parent b8405d739149cdd6d8d9bd5e3dd2ad8487b1f09a
streamclone: use read()
We have a convenience API for reading the full contents of a file.
Use it.
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -207,22 +207,17 @@ def generatev1(repo):
def emitrevlogdata():
try:
for name, size in entries:
if debugflag:
repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
# 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
finally:
svfs.mustaudit = oldaudit
return len(entries), total_bytes, emitrevlogdata()
More information about the Mercurial-devel
mailing list