# HG changeset patch # User Yuya Nishihara # Date 2017-07-07 14:25:16 # Node ID c784308305c6cdd4f968ea54e79ca8a71f172103 # Parent 50243c975fc2ee605ebac493f4ab18d37117e46a streamclone: close large revlog files explicitly in generatev1() diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -221,13 +221,12 @@ def generatev1(repo): 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: - with svfs(name, 'rb', auditpath=False) as fp: + with svfs(name, 'rb', auditpath=False) as fp: + if size <= 65536: yield fp.read(size) - else: - data = svfs(name, auditpath=False) - for chunk in util.filechunkiter(data, limit=size): - yield chunk + else: + for chunk in util.filechunkiter(fp, limit=size): + yield chunk return len(entries), total_bytes, emitrevlogdata()