changeset 40519:3c4b9dace7de

ui: consolidate places where _progclear() is called The progress bar has to be cleared when we start writing some data to the output stream. Let's make it always triggered immediately before switching by _colormode, so that we can easily factor out helper functions.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Nov 2018 16:04:16 +0900
parents d11e2c5b287e
children fd60c2afb484
files mercurial/ui.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Sun Nov 04 20:44:26 2018 +0900
+++ b/mercurial/ui.py	Sat Nov 03 16:04:16 2018 +0900
@@ -950,6 +950,7 @@
             self._writenobuf(*args, **opts)
 
     def _writenobuf(self, *args, **opts):
+        self._progclear()
         if self._colormode == 'win32':
             # windows color printing is its own can of crab, defer to
             # the color module and that is it.
@@ -962,7 +963,6 @@
             self._write(*msgs, **opts)
 
     def _write(self, *msgs, **opts):
-        self._progclear()
         # opencode timeblockedsection because this is a critical path
         starttime = util.timer()
         try:
@@ -974,10 +974,11 @@
                 (util.timer() - starttime) * 1000
 
     def write_err(self, *args, **opts):
-        self._progclear()
         if self._bufferstates and self._bufferstates[-1][0]:
             self.write(*args, **opts)
-        elif self._colormode == 'win32':
+            return
+        self._progclear()
+        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_err, *args, **opts)