progress: respect ui.quiet (issue4726)
authorAugie Fackler <augie@google.com>
Tue, 16 Jun 2015 14:11:58 -0400
changeset 25653 79c75459321e1e14bf081a16947e7a03f6c8e5a5
parent 25652 a69983942fb4dbfdf5ca8c7a123120ed09ead5db
child 25654 5fa399a0c385c7e3eba0c35366b222d982438b0c
push id14
push usergszorc@mozilla.com
push dateMon, 22 Jun 2015 07:28:19 +0000
progress: respect ui.quiet (issue4726) Caught when I was running the hgsubversion testsuite and it started printing progress bars over top of my test output lines.
mercurial/progress.py
tests/test-progress.t
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -12,18 +12,18 @@ from mercurial import encoding
 
 from mercurial.i18n import _
 
 
 def spacejoin(*args):
     return ' '.join(s for s in args if s)
 
 def shouldprint(ui):
-    return not ui.plain() and (ui._isatty(sys.stderr) or
-                               ui.configbool('progress', 'assume-tty'))
+    return not (ui.quiet or ui.plain()) and (
+        ui._isatty(sys.stderr) or ui.configbool('progress', 'assume-tty'))
 
 def fmtremaining(seconds):
     """format a number of remaining seconds in humain readable way
 
     This will properly display seconds, minutes, hours, days if needed"""
     if seconds < 60:
         # i18n: format XX seconds as "XXs"
         return _("%02ds") % (seconds)
@@ -244,9 +244,8 @@ class progbar(object):
                 self.topicstates[topic] = pos, item, unit, total
                 self.curtopic = topic
                 if now - self.lastprint >= self.refresh and self.topics:
                     if self._oktoprint(now):
                         self.lastprint = now
                         self.show(now, topic, *self.topicstates[topic])
         finally:
             self._refreshlock.release()
-
--- a/tests/test-progress.t
+++ b/tests/test-progress.t
@@ -71,17 +71,18 @@ test default params, display nothing bec
 test with delay=0, refresh=0
 
   $ hg -y loop 3
   \r (no-eol) (esc)
   loop [                                                ] 0/3\r (no-eol) (esc)
   loop [===============>                                ] 1/3\r (no-eol) (esc)
   loop [===============================>                ] 2/3\r (no-eol) (esc)
                                                               \r (no-eol) (esc)
-
+no progress with --quiet
+  $ hg -y loop 3 --quiet
 
 test nested short-lived topics (which shouldn't display with nestdelay):
 
   $ hg -y loop 3 --nested
   \r (no-eol) (esc)
   loop [                                                ] 0/3\r (no-eol) (esc)
   loop [===============>                                ] 1/3\r (no-eol) (esc)
   loop [===============================>                ] 2/3\r (no-eol) (esc)