Patchwork [1,of,3] streamclone: close large revlog files explicitly in generatev1()

login
register
mail settings
Submitter Yuya Nishihara
Date July 7, 2017, 3:14 p.m.
Message ID <975c99e7fc675b5f1f89.1499440441@mimosa>
Download mbox | patch
Permalink /patch/22100/
State Accepted
Headers show

Comments

Yuya Nishihara - July 7, 2017, 3:14 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1499437516 -32400
#      Fri Jul 07 23:25:16 2017 +0900
# Node ID 975c99e7fc675b5f1f89b348cc91651e0d48eb61
# Parent  de50a2f8fd984912893b6aea79cd0d7ab0b83299
streamclone: close large revlog files explicitly in generatev1()

Patch

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()