[PATCH STABLE] progress: stop excessive clearing (issue4801)

Matt Mackall mpm at selenic.com
Fri May 6 22:53:52 UTC 2016


# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1462575186 18000
#      Fri May 06 17:53:06 2016 -0500
# Branch stable
# Node ID 222b8170d69e74ed6970a51b73e83042a1b87b92
# Parent  77de985d7c91c67650d9fba0e4b21dfdbd894eeb
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.

diff -r 77de985d7c91 -r 222b8170d69e mercurial/progress.py
--- 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:
diff -r 77de985d7c91 -r 222b8170d69e tests/test-remove.t
--- a/tests/test-remove.t	Thu May 05 16:29:31 2016 +0200
+++ b/tests/test-remove.t	Fri May 06 17:53:06 2016 -0500
@@ -322,8 +322,6 @@
   \r (no-eol) (esc)
   deleting [===========================================>] 2/2\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
-  \r (no-eol) (esc)
-                                                              \r (no-eol) (esc)
   removing test/bar (glob)
   removing test/foo (glob)
   exit code: 0
@@ -348,8 +346,6 @@
   \r (no-eol) (esc)
   deleting [===========================================>] 2/2\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
-  \r (no-eol) (esc)
-                                                              \r (no-eol) (esc)
   removing test/bar (glob)
   removing test/foo (glob)
   exit code: 0
@@ -374,8 +370,6 @@
   \r (no-eol) (esc)
   deleting [===========================================>] 1/1\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
-  \r (no-eol) (esc)
-                                                              \r (no-eol) (esc)
   removing test/bar (glob)
   not removing test/foo: file still exists (glob)
   exit code: 1
@@ -400,8 +394,6 @@
   \r (no-eol) (esc)
   deleting [===========================================>] 2/2\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
-  \r (no-eol) (esc)
-                                                              \r (no-eol) (esc)
   removing test/bar (glob)
   removing test/foo (glob)
   exit code: 0
@@ -429,8 +421,6 @@
   \r (no-eol) (esc)
   deleting [===========================================>] 1/1\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
-  \r (no-eol) (esc)
-                                                              \r (no-eol) (esc)
   removing issue1861/b/c/y (glob)
   $ hg ci -m remove
   $ ls issue1861
@@ -465,8 +455,6 @@
   \r (no-eol) (esc)
   deleting [===========================================>] 1/1\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
-  \r (no-eol) (esc)
-                                                              \r (no-eol) (esc)
   removing d1/a (glob)
 
   $ hg rm --after nosuch
diff -r 77de985d7c91 -r 222b8170d69e tests/test-subrepo-deep-nested-change.t
--- a/tests/test-subrepo-deep-nested-change.t	Thu May 05 16:29:31 2016 +0200
+++ b/tests/test-subrepo-deep-nested-change.t	Fri May 06 17:53:06 2016 -0500
@@ -214,8 +214,6 @@
   \r (no-eol) (esc)
   deleting [===========================================>] 2/2\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
-  \r (no-eol) (esc)
-                                                              \r (no-eol) (esc)
   removing sub1/sub2/folder/test.txt (glob)
   removing sub1/sub2/test.txt (glob)
   $ hg status -S


More information about the Mercurial-devel mailing list