changeset 28633:e35d7f131483

ui: add prompt argument to write (issue5154) (API) When code like filemerge._iprompt calls ui.prompt, it expects the user to see the output in addition to getting the prompt. Other code such as histedit may call ui.pushbuffer, but its goal is not to interfere with prompts, so this commit adds an optional prompt flag to ui.write and has _readline include that argument. ui.promptchoice calls ui.prompt which calls ui._readline. This commit also updates hgext.color.write.
author timeless <timeless@mozdev.org>
date Fri, 25 Mar 2016 21:51:00 +0000
parents c2e4e59aaea6
children 3ceac01bc29f
files hgext/color.py mercurial/ui.py
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/color.py	Sat Mar 26 10:53:31 2016 +0900
+++ b/hgext/color.py	Fri Mar 25 21:51:00 2016 +0000
@@ -424,7 +424,7 @@
             return super(colorui, self).write(*args, **opts)
 
         label = opts.get('label', '')
-        if self._buffers:
+        if self._buffers and not opts.get('prompt', False):
             if self._bufferapplylabels:
                 self._buffers[-1].extend(self.label(a, label) for a in args)
             else:
--- a/mercurial/ui.py	Sat Mar 26 10:53:31 2016 +0900
+++ b/mercurial/ui.py	Fri Mar 25 21:51:00 2016 +0000
@@ -662,7 +662,7 @@
         "cmdname.type" is recommended. For example, status issues
         a label of "status.modified" for modified files.
         '''
-        if self._buffers:
+        if self._buffers and not opts.get('prompt', False):
             self._buffers[-1].extend(a for a in args)
         else:
             self._progclear()
@@ -842,7 +842,7 @@
 
         # call write() so output goes through subclassed implementation
         # e.g. color extension on Windows
-        self.write(prompt)
+        self.write(prompt, prompt=True)
 
         # instead of trying to emulate raw_input, swap (self.fin,
         # self.fout) with (sys.stdin, sys.stdout)