diff mercurial/chgserver.py @ 38801:23a00bc90a3c stable

chgserver: do not send system() back to client if stdio redirected (issue5992) As the chg client doesn't know server-side stdio redirection, the server shouldn't upcall on "runsystem" request if the stdio streams are redirected. This patch teaches ui to remember the redirection flag, which is updated by the caller right now. Future patches (for default) will add ui methods to manage this flag internally.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 26 Sep 2018 21:24:14 +0900
parents 1b9be0b26511
children a9f56e4501c1
line wrap: on
line diff
--- a/mercurial/chgserver.py	Wed Sep 26 21:21:05 2018 +0900
+++ b/mercurial/chgserver.py	Wed Sep 26 21:24:14 2018 +0900
@@ -200,11 +200,13 @@
         def _runsystem(self, cmd, environ, cwd, out):
             # fallback to the original system method if
             #  a. the output stream is not stdout (e.g. stderr, cStringIO),
+            #  b. or stdout is redirected by protectstdio(),
             # because the chg client is not aware of these situations and
             # will behave differently (i.e. write to stdout).
             if (out is not self.fout
                 or not util.safehasattr(self.fout, 'fileno')
-                or self.fout.fileno() != procutil.stdout.fileno()):
+                or self.fout.fileno() != procutil.stdout.fileno()
+                or self._finoutredirected):
                 return procutil.system(cmd, environ=environ, cwd=cwd, out=out)
             self.flush()
             return self._csystem(cmd, procutil.shellenviron(environ), cwd)