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

login
register
mail settings
Submitter Pierre-Yves David
Date May 20, 2015, 11:53 p.m.
Message ID <f0f5363aafdce72c1893.1432166003@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9209/
State Accepted
Headers show

Comments

Pierre-Yves David - May 20, 2015, 11:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.

Patch

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)