ui: consolidate places where _progclear() is called
authorYuya Nishihara <yuya@tcha.org>
Sat, 03 Nov 2018 16:04:16 +0900
changeset 40519 3c4b9dace7de
parent 40518 d11e2c5b287e
child 40520 fd60c2afb484
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.
mercurial/ui.py
--- 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)