Patchwork progress: force a repaint of a printed progress bar after a clear()

login
register
mail settings
Submitter Augie Fackler
Date Sept. 28, 2015, 1:50 p.m.
Message ID <f14ed960b2822f3b0703.1443448204@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/10667/
State Accepted
Headers show

Comments

Augie Fackler - Sept. 28, 2015, 1:50 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.
Pierre-Yves David - Sept. 29, 2015, 6:48 p.m.
On 09/28/2015 06:50 AM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@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()

That one have been pushed to the clowncopter but initial notification 
got eaten by a grue.

Patch

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):