diff mercurial/progress.py @ 29089:222b8170d69e stable

progress: stop excessive clearing (issue4801) The progress bar was being cleared on every write(), regardless of whether it was currently displayed. This could foul up the display of any writes that didn't include a linebreak. In particular, the win32 mode of the color extension was turning single prompt string writes into two writes, and the resulting clear/write/clear/write pattern was making the prompt invisible. We fix this by insisting that we have shown a progress bar and haven't just cleared it (setting lastprint to 0). Conveniently, the test suite already had instances of duplicate clears.. that are now cleared up.
author Matt Mackall <mpm@selenic.com>
date Fri, 06 May 2016 17:53:06 -0500
parents 2d20d1d2ea76
children cb1ea3cc44b5
line wrap: on
line diff
--- a/mercurial/progress.py	Thu May 05 16:29:31 2016 +0200
+++ b/mercurial/progress.py	Fri May 06 17:53:06 2016 -0500
@@ -163,7 +163,7 @@
         sys.stderr.flush()
 
     def clear(self):
-        if not shouldprint(self.ui):
+        if not self.printed or not self.lastprint or not shouldprint(self.ui):
             return
         sys.stderr.write('\r%s\r' % (' ' * self.width()))
         if self.printed: