[PATCH 2 of 4 STABLE follow-up] streamclone: use readexactly when reading stream v2

Boris Feld boris.feld at octobus.net
Fri Jan 26 11:07:30 EST 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1516826671 -3600
#      Wed Jan 24 21:44:31 2018 +0100
# Branch stable
# Node ID ba834f589608bfc7ad88a29b22941f322c598760
# Parent  7d4c20e651bebd76f09183681ba9d743834dc53d
# EXP-Topic b2-stream
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ba834f589608
streamclone: use readexactly when reading stream v2

Yuya Nishihara pointed out that it is safer.

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -594,12 +594,12 @@ def consumev2(repo, fp, filecount, files
                     for vfs in vfsmap.values())
             with nested(*ctxs):
                 for i in range(filecount):
-                    src = fp.read(1)
+                    src = util.readexactly(fp, 1)
                     vfs = vfsmap[src]
                     namelen = util.uvarintdecodestream(fp)
                     datalen = util.uvarintdecodestream(fp)
 
-                    name = fp.read(namelen)
+                    name = util.readexactly(fp, namelen)
 
                     if repo.ui.debugflag:
                         repo.ui.debug('adding [%s] %s (%s)\n' %


More information about the Mercurial-devel mailing list