[PATCH 1 of 6] ui: consolidate places where _progclear() is called

Yuya Nishihara yuya at tcha.org
Sun Nov 4 12:55:21 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1541228656 -32400
#      Sat Nov 03 16:04:16 2018 +0900
# Node ID 86c9952592c51f6ce45eb44c59214e5a68a463df
# Parent  78e5b9d815facdba962950aad03e8e1b3ae60288
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.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -950,6 +950,7 @@ class ui(object):
             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 @@ class ui(object):
             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 @@ class ui(object):
                 (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)


More information about the Mercurial-devel mailing list