Rev 4967: (mbp) --quiet now turns off progress bars in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Jan 15 08:18:06 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4967 [merge]
revision-id: pqm at pqm.ubuntu.com-20100115081803-228osuav8adlz7z4
parent: pqm at pqm.ubuntu.com-20100115073610-fhh709ihgalxy9b8
parent: mbp at sourcefrog.net-20100115074510-ayjxsw9veh21ffl2
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-01-15 08:18:03 +0000
message:
(mbp) --quiet now turns off progress bars
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/per_uifactory/__init__.py __init__.py-20090923045301-o12zypjwsidxn2hy-1
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/trace.py trace.py-20050309040759-c8ed824bdcd4748a
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
=== modified file 'NEWS'
--- a/NEWS 2010-01-15 07:36:10 +0000
+++ b/NEWS 2010-01-15 08:18:03 +0000
@@ -93,6 +93,9 @@
* Listen to the SIGWINCH signal to update the terminal width.
(Vincent Ladeuil, #316357)
+* Progress bars are now hidden when ``--quiet`` is given.
+ (Martin Pool, #320035)
+
* ``SilentUIFactory`` now supports ``make_output_stream`` and discards
whatever is written to it. This un-breaks some plugin tests that
depended on this behaviour.
=== modified file 'bzrlib/tests/per_uifactory/__init__.py'
--- a/bzrlib/tests/per_uifactory/__init__.py 2010-01-14 08:20:18 +0000
+++ b/bzrlib/tests/per_uifactory/__init__.py 2010-01-15 07:45:10 +0000
@@ -56,6 +56,12 @@
the concrete subclasses should be.
"""
+ def test_be_quiet(self):
+ self.factory.be_quiet(True)
+ self.assertEquals(True, self.factory.is_quiet())
+ self.factory.be_quiet(False)
+ self.assertEquals(False, self.factory.is_quiet())
+
def test_note(self):
self.factory.note("a note to the user")
self._check_note("a note to the user")
=== modified file 'bzrlib/tests/test_ui.py'
--- a/bzrlib/tests/test_ui.py 2009-12-10 16:54:28 +0000
+++ b/bzrlib/tests/test_ui.py 2010-01-15 03:29:33 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2008, 2009 Canonical Ltd
+# Copyright (C) 2005, 2008, 2009, 2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -248,6 +248,17 @@
finally:
pb.finished()
+ def test_quietness(self):
+ os.environ['BZR_PROGRESS_BAR'] = 'text'
+ ui_factory = _mod_ui_text.TextUIFactory(None,
+ test_progress._TTYStringIO(),
+ test_progress._TTYStringIO())
+ self.assertIsInstance(ui_factory._progress_view,
+ _mod_ui_text.TextProgressView)
+ ui_factory.be_quiet(True)
+ self.assertIsInstance(ui_factory._progress_view,
+ _mod_ui_text.NullProgressView)
+
class TestTextUIOutputStream(tests.TestCase):
"""Tests for output stream that synchronizes with progress bar."""
=== modified file 'bzrlib/trace.py'
--- a/bzrlib/trace.py 2010-01-12 06:30:41 +0000
+++ b/bzrlib/trace.py 2010-01-15 03:29:33 +0000
@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-"""Messages and logging for bazaar-ng.
+"""Messages and logging.
Messages are supplied by callers as a string-formatting template, plus values
to be inserted into it. The actual %-formatting is deferred to the log
@@ -33,8 +33,7 @@
Output to stderr depends on the mode chosen by the user. By default, messages
of info and above are sent out, which results in progress messages such as the
-list of files processed by add and commit. In quiet mode, only warnings and
-above are shown. In debug mode, stderr gets debug messages too.
+list of files processed by add and commit. In debug mode, stderr gets debug messages too.
Errors that terminate an operation are generally passed back as exceptions;
others may be just emitted as messages.
@@ -83,6 +82,7 @@
osutils,
plugin,
symbol_versioning,
+ ui,
)
""")
@@ -365,6 +365,7 @@
global _verbosity_level
_verbosity_level = level
_update_logging_level(level < 0)
+ ui.ui_factory.be_quiet(level < 0)
def get_verbosity_level():
@@ -376,7 +377,6 @@
def be_quiet(quiet=True):
- # Perhaps this could be deprecated now ...
if quiet:
set_verbosity_level(-1)
else:
=== modified file 'bzrlib/ui/__init__.py'
--- a/bzrlib/ui/__init__.py 2010-01-15 07:00:49 +0000
+++ b/bzrlib/ui/__init__.py 2010-01-15 08:18:03 +0000
@@ -109,6 +109,15 @@
def __init__(self):
self._task_stack = []
+ self._quiet = False
+
+ def be_quiet(self, state):
+ """Tell the UI to be more quiet, or not.
+
+ Typically this suppresses progress bars; the application may also look
+ at ui_factory.is_quiet().
+ """
+ self._quiet = state
def get_password(self, prompt='', **kwargs):
"""Prompt the user for a password.
@@ -125,6 +134,9 @@
"""
raise NotImplementedError(self.get_password)
+ def is_quiet(self):
+ return self._quiet
+
def make_output_stream(self, encoding=None, encoding_type=None):
"""Get a stream for sending out bulk text data.
=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py 2010-01-05 04:30:07 +0000
+++ b/bzrlib/ui/text.py 2010-01-15 03:29:33 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2008, 2009 Canonical Ltd
+# Copyright (C) 2005, 2008, 2009, 2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -61,6 +61,12 @@
# paints progress, network activity, etc
self._progress_view = self.make_progress_view()
+ def be_quiet(self, state):
+ if state and not self._quiet:
+ self.clear_term()
+ UIFactory.be_quiet(self, state)
+ self._progress_view = self.make_progress_view()
+
def clear_term(self):
"""Prepare the terminal for output.
@@ -146,9 +152,13 @@
def make_progress_view(self):
"""Construct and return a new ProgressView subclass for this UI.
"""
- # if the user specifically requests either text or no progress bars,
- # always do that. otherwise, guess based on $TERM and tty presence.
- if os.environ.get('BZR_PROGRESS_BAR') == 'text':
+ # with --quiet, never any progress view
+ # <https://bugs.edge.launchpad.net/bzr/+bug/320035>. Otherwise if the
+ # user specifically requests either text or no progress bars, always
+ # do that. otherwise, guess based on $TERM and tty presence.
+ if self.is_quiet():
+ return NullProgressView()
+ elif os.environ.get('BZR_PROGRESS_BAR') == 'text':
return TextProgressView(self.stderr)
elif os.environ.get('BZR_PROGRESS_BAR') == 'none':
return NullProgressView()
More information about the bazaar-commits
mailing list