ui: add explicit path to write prompt text bypassing buffers
authorYuya Nishihara <yuya@tcha.org>
Mon, 05 Feb 2018 20:48:51 +0900
changeset 35996 b62c4154bb28
parent 35995 fd54846e1f8e
child 35997 fd9f2a22ee83
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.
mercurial/ui.py
--- a/mercurial/ui.py	Mon Feb 05 20:40:49 2018 +0900
+++ b/mercurial/ui.py	Mon Feb 05 20:48:51 2018 +0900
@@ -886,13 +886,17 @@
         "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 @@
         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()