changeset 5613:2e76e5a23c2b

workaround for raw_input() on Windows Since change a3fe91b4f6eb, Mercurial has set_binary() on stdin, stdout, and stderr. On Windows, this had the side effect of causing raw_input() to emit trailing carriage returns on it's returned strings. This was causing web authentication problems.
author Steve Borho <steve@borho.org>
date Mon, 03 Dec 2007 17:28:26 -0600
parents 7c976bb039af
children ce383c80a177
files mercurial/ui.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Tue Dec 04 23:28:10 2007 +0100
+++ b/mercurial/ui.py	Mon Dec 03 17:28:26 2007 -0600
@@ -403,7 +403,12 @@
                 readline.read_history_file
             except ImportError:
                 pass
-        return raw_input(prompt)
+        line = raw_input(prompt)
+        # When stdin is in binary mode on Windows, it can cause
+        # raw_input() to emit an extra trailing carriage return
+        if os.linesep == '\r\n' and line and line[-1] == '\r':
+            line = line[:-1]
+        return line
 
     def prompt(self, msg, pat=None, default="y", matchflags=0):
         if not self.interactive: return default