progress: stop excessive clearing (issue4801) stable
authorMatt Mackall <mpm@selenic.com>
Fri, 06 May 2016 17:53:06 -0500
branchstable
changeset 29089 222b8170d69e
parent 29082 77de985d7c91
child 29090 7b52cb384c38
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.
mercurial/progress.py
tests/test-remove.t
tests/test-subrepo-deep-nested-change.t
--- 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:
--- 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
--- 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