ui: also swap sys.stdout with self.fout in _readline

In 55a66b5d9114, _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.
This commit is contained in:
Martin Geisler 2011-08-30 14:18:58 +02:00
parent 9fe3bba5d0
commit 9b3666843e

View File

@ -541,11 +541,15 @@ class ui(object):
# 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