[PATCH] progress: force a repaint of a printed progress bar after a clear()

Augie Fackler raf at durin42.com
Mon Sep 28 13:50:04 UTC 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1443240648 14400
#      Sat Sep 26 00:10:48 2015 -0400
# Node ID f14ed960b2822f3b0703ed19f1da8eab0cd6d13a
# Parent  53371aed1ed51d6598a1368cc1605b782d75fede
progress: force a repaint of a printed progress bar after a clear()

This avoids some visual flickering of the progress bar in convert and
probably some other operations. Previously, a line of output would
erase the progress bar, and then it would wait `progress.refresh`
seconds (default of 0.1) before redrawing the progress bar. Now if
we've ever painted a progress bar, we schedule the progress bar for
immediate repainting on the next progress call, which helps lend the
illusion that the progress bar is "always" there. In practice, it's
merely there more of the time, but it ends up being a lot easier to
read during convert.

diff --git a/mercurial/progress.py b/mercurial/progress.py
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -166,6 +166,9 @@ class progbar(object):
         if not shouldprint(self.ui):
             return
         sys.stderr.write('\r%s\r' % (' ' * self.width()))
+        if self.printed:
+            # force immediate re-paint of progress bar
+            self.lastprint = 0
 
     def complete(self):
         if not shouldprint(self.ui):


More information about the Mercurial-devel mailing list