changeset 35956:fd54846e1f8e

ui: write prompt text in ui.prompt(), not in ui._readline() self.label() is replaced by label= option, which should make it clearer why we can't pass the text to raw_input(prompt).
author Yuya Nishihara <yuya@tcha.org>
date Mon, 05 Feb 2018 20:40:49 +0900
parents 218b77c4c87a
children b62c4154bb28
files mercurial/ui.py
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Sun Jan 21 14:00:56 2018 +0900
+++ b/mercurial/ui.py	Mon Feb 05 20:40:49 2018 +0900
@@ -1246,7 +1246,7 @@
 
         return i
 
-    def _readline(self, prompt=''):
+    def _readline(self):
         if self._isatty(self.fin):
             try:
                 # magically add command line editing support, where
@@ -1258,11 +1258,6 @@
             except Exception:
                 pass
 
-        # call write() so output goes through subclassed implementation
-        # e.g. color extension on Windows
-        self.write(prompt, prompt=True)
-        self.flush()
-
         # prompt ' ' must exist; otherwise readline may delete entire line
         # - http://bugs.python.org/issue12833
         with self.timeblockedsection('stdio'):
@@ -1281,8 +1276,10 @@
         if not self.interactive():
             self.write(msg, ' ', default or '', "\n")
             return default
+        self.write(msg, label='ui.prompt', prompt=True)
+        self.flush()
         try:
-            r = self._readline(self.label(msg, 'ui.prompt'))
+            r = self._readline()
             if not r:
                 r = default
             if self.configbool('ui', 'promptecho'):