procutil: use unbuffered stdout on Windows
authorSune Foldager <cryo@cyanite.org>
Mon, 25 Jun 2018 16:36:14 +0200
changeset 38454 d24ad71ff869
parent 38453 5cdfc20bfd5f
child 38456 1cac2e8c7624
procutil: use unbuffered stdout on Windows Windows doesn't support line buffering, treating it as fully buffered. This causes output of slow commands to stutter. We use unbuffered instead.
mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py	Fri May 25 18:16:38 2018 +0530
+++ b/mercurial/utils/procutil.py	Mon Jun 25 16:36:14 2018 +0200
@@ -41,9 +41,13 @@
 
 # glibc determines buffering on first write to stdout - if we replace a TTY
 # destined stdout with a pipe destined stdout (e.g. pager), we want line
-# buffering
+# buffering (or unbuffered, on Windows)
 if isatty(stdout):
-    stdout = os.fdopen(stdout.fileno(), r'wb', 1)
+    if pycompat.iswindows:
+        # Windows doesn't support line buffering
+        stdout = os.fdopen(stdout.fileno(), r'wb', 0)
+    else:
+        stdout = os.fdopen(stdout.fileno(), r'wb', 1)
 
 if pycompat.iswindows:
     from .. import windows as platform