[PATCH 4 of 5] util: allow to specify buffer size in popen4

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed May 20 18:53:23 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1432139385 18000
#      Wed May 20 11:29:45 2015 -0500
# Node ID f0f5363aafdce72c18936ab478480a47b230a941
# Parent  687fd403550ff2fd9eec1fbc00c3978ae3d95da8
util: allow to specify buffer size in popen4

We will need unbuffered IO to restore real time output with ssh peer.

Changeset ec171737aaf1 seems to indicate playing with this value could be
dangerous, but does not indicate why.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -245,12 +245,12 @@ def popen2(cmd, env=None, newlines=False
 
 def popen3(cmd, env=None, newlines=False):
     stdin, stdout, stderr, p = popen4(cmd, env, newlines)
     return stdin, stdout, stderr
 
-def popen4(cmd, env=None, newlines=False):
-    p = subprocess.Popen(cmd, shell=True, bufsize=-1,
+def popen4(cmd, env=None, newlines=False, bufsize=-1):
+    p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
                          close_fds=closefds,
                          stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE,
                          universal_newlines=newlines,
                          env=env)


More information about the Mercurial-devel mailing list