From patchwork Mon Feb 5 12:11:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,2] ui: write prompt text in ui.prompt(), not in ui._readline() From: Yuya Nishihara X-Patchwork-Id: 27308 Message-Id: <9be8a0f8d48502734066.1517832713@mimosa> To: mercurial-devel@mercurial-scm.org Date: Mon, 05 Feb 2018 21:11:53 +0900 # HG changeset patch # User Yuya Nishihara # Date 1517830849 -32400 # Mon Feb 05 20:40:49 2018 +0900 # Node ID 9be8a0f8d48502734066a66e3d5b9b22e460ae70 # Parent a9802c9ecfb5aa20d89480763ae15b03f78f3a88 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). diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1246,7 +1246,7 @@ class ui(object): 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 @@ class ui(object): 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 @@ class ui(object): 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'):