Patchwork [2,of,2] ui: add explicit path to write prompt text bypassing buffers

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 5, 2018, 12:11 p.m.
Message ID <59869758acd7b38d9de0.1517832714@mimosa>
Download mbox | patch
Permalink /patch/27309/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 5, 2018, 12:11 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1517831331 -32400
#      Mon Feb 05 20:48:51 2018 +0900
# Node ID 59869758acd7b38d9de045d5a72f5196cc80f047
# Parent  9be8a0f8d48502734066a66e3d5b9b22e460ae70
ui: add explicit path to write prompt text bypassing buffers

The prompt= flag was added at e35d7f131483, when colorui had its own write()
function. Since we've merged colorui to ui, we can simply call the unbuffered
write() function.
Augie Fackler - Feb. 7, 2018, 11:35 a.m.
> On Feb 5, 2018, at 13:11, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1517831331 -32400
> #      Mon Feb 05 20:48:51 2018 +0900
> # Node ID 59869758acd7b38d9de045d5a72f5196cc80f047
> # Parent  9be8a0f8d48502734066a66e3d5b9b22e460ae70
> ui: add explicit path to write prompt text bypassing buffers

queued, thanks

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -886,13 +886,17 @@  class ui(object):
         "cmdname.type" is recommended. For example, status issues
         a label of "status.modified" for modified files.
         '''
-        if self._buffers and not opts.get(r'prompt', False):
+        if self._buffers:
             if self._bufferapplylabels:
                 label = opts.get(r'label', '')
                 self._buffers[-1].extend(self.label(a, label) for a in args)
             else:
                 self._buffers[-1].extend(args)
-        elif self._colormode == 'win32':
+        else:
+            self._writenobuf(*args, **opts)
+
+    def _writenobuf(self, *args, **opts):
+        if self._colormode == 'win32':
             # windows color printing is its own can of crab, defer to
             # the color module and that is it.
             color.win32print(self, self._write, *args, **opts)
@@ -1276,7 +1280,7 @@  class ui(object):
         if not self.interactive():
             self.write(msg, ' ', default or '', "\n")
             return default
-        self.write(msg, label='ui.prompt', prompt=True)
+        self._writenobuf(msg, label='ui.prompt')
         self.flush()
         try:
             r = self._readline()