ui: also swap sys.stdout with self.fout in _readline stable
authorMartin Geisler <mg@aragost.com>
Tue, 30 Aug 2011 14:18:58 +0200
branchstable
changeset 15062 0fc95f5cea57
parent 15060 01cdfba22f0c
child 15063 c20688b7c061
ui: also swap sys.stdout with self.fout in _readline In 17ffb30d9174, _readline was changed to output a space using raw_input and this was done using sys.stdout directly, not self.fout. This change broke the command server for JavaHg since it (and other clients) would see a spurious ' ' on stdout and interpret this as an unknown channel.
mercurial/ui.py
--- a/mercurial/ui.py	Fri Aug 26 16:07:16 2011 -0500
+++ b/mercurial/ui.py	Tue Aug 30 14:18:58 2011 +0200
@@ -541,11 +541,15 @@
         # e.g. color extension on Windows
         self.write(prompt)
 
-        # instead of trying to emulate raw_input, swap self.fin with sys.stdin
-        old = sys.stdin
+        # instead of trying to emulate raw_input, swap (self.fin,
+        # self.fout) with (sys.stdin, sys.stdout)
+        oldin = sys.stdin
+        oldout = sys.stdout
         sys.stdin = self.fin
+        sys.stdout = self.fout
         line = raw_input(' ')
-        sys.stdin = old
+        sys.stdin = oldin
+        sys.stdout = oldout
 
         # When stdin is in binary mode on Windows, it can cause
         # raw_input() to emit an extra trailing carriage return