[PATCH 2 of 3 side-word (+4)] sshpeer: use a 'bufferedinputpipe' for standard output of the ssh process

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun May 31 02:22:33 CDT 2015

# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1433055636 25200
#      Sun May 31 00:00:36 2015 -0700
# Node ID 72344e96acd26c68121d747aeb77fb8e1f9a75e8
# Parent  1a883412355af1e057324b4ab2de885473f54432
sshpeer: use a 'bufferedinputpipe' for standard output of the ssh process

We need this pipe to still be buffered when will switch to unbuffered pipe.
(switch motivated by the need of using polling to restore real time output from
ssh server). This is the only pipe that needs to be wrapped because this is the
one who do extensive usage of 'readline'. The stderr pipe of the process is
alway read in non blocking raw chunk, so it won't benefit from the

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -87,10 +87,12 @@ class sshpeer(wireproto.wirepeer):
         # while self.subprocess isn't used, having it allows the subprocess to
         # to clean up correctly later
         self.pipeo, self.pipei, self.pipee, self.subprocess = util.popen4(cmd)
+        self.pipei = util.bufferedinputpipe(self.pipei)
         # skip any noise generated by remote shell
         r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
         lines = ["", "dummy"]
         max_noise = 500

More information about the Mercurial-devel mailing list