# HG changeset patch # User Matt Mackall # Date 2016-05-06 22:53:06 # 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 --git a/mercurial/progress.py b/mercurial/progress.py --- a/mercurial/progress.py +++ b/mercurial/progress.py @@ -163,7 +163,7 @@ class progbar(object): 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 --git a/tests/test-remove.t b/tests/test-remove.t --- a/tests/test-remove.t +++ b/tests/test-remove.t @@ -322,8 +322,6 @@ dir, options none \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 @@ dir, options -f \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 @@ dir, options -A \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 @@ dir, options -Af \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 @@ test remove dropping empty trees (issue1 \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 @@ handling of untracked directories and mi \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 --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t +++ b/tests/test-subrepo-deep-nested-change.t @@ -214,8 +214,6 @@ Check that deep archiving works \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