Merge lp:~mbp/bzr/339385-set-progress-bar into lp:~bzr/bzr/trunk-old

Proposed by Martin Pool
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mbp/bzr/339385-set-progress-bar
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 204 lines
To merge this branch: bzr merge lp:~mbp/bzr/339385-set-progress-bar
Reviewer Review Type Date Requested Status
Robert Collins (community) Needs Fixing
Review via email: mp+7534@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

This fixes this annoying bug that support for turning off progress bars regressed.

It also removes an over-specific error message; I doubt users really want bzr to fail if it won't support their progress bar preference, and it's even less likely code will want to specifically catch that case.

Revision history for this message
Robert Collins (lifeless) wrote :

This looks fine.
However dropping the exception is an API break; please update the
minimum api version in __init__.py accordingly.

 review needsfixing

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-06-17 02:02:44 +0000
+++ NEWS 2009-06-17 08:35:26 +0000
@@ -23,6 +23,10 @@
23* ``Branch.set_append_revisions_only`` now works with branches on a smart23* ``Branch.set_append_revisions_only`` now works with branches on a smart
24 server. (Andrew Bennetts, #365865)24 server. (Andrew Bennetts, #365865)
2525
26* Progress bars are now suppressed again when the environment variable
27 ``BZR_PROGRESS_BAR`` is set to ``none``.
28 (Martin Pool, #339385)
29
26Internals30Internals
27*********31*********
2832
@@ -53,6 +57,16 @@
53* Minor clarifications to the help for End-Of-Line conversions.57* Minor clarifications to the help for End-Of-Line conversions.
54 (Ian Clatworthy)58 (Ian Clatworthy)
5559
60API Changes
61***********
62
63* Removed overspecific error class ``InvalidProgressBarType``.
64 (Martin Pool)
65
66* The method ``ProgressView._show_transport_activity`` is now
67 ``show_transport_activity`` because it's part of the contract between
68 this class and the UI. (Martin Pool)
69
5670
57bzr 1.16rc1 "It's yesterday in California" 2009-06-1171bzr 1.16rc1 "It's yesterday in California" 2009-06-11
58#####################################################72#####################################################
5973
=== modified file 'bzrlib/__init__.py'
--- bzrlib/__init__.py 2009-06-12 08:38:52 +0000
+++ bzrlib/__init__.py 2009-06-17 08:35:26 +0000
@@ -53,7 +53,7 @@
53version_info = (1, 17, 0, 'dev', 0)53version_info = (1, 17, 0, 'dev', 0)
5454
55# API compatibility version: bzrlib is currently API compatible with 1.15.55# API compatibility version: bzrlib is currently API compatible with 1.15.
56api_minimum_version = (1, 15, 0)56api_minimum_version = (1, 17, 0)
5757
58def _format_version_tuple(version_info):58def _format_version_tuple(version_info):
59 """Turn a version number 2, 3 or 5-tuple into a short string.59 """Turn a version number 2, 3 or 5-tuple into a short string.
6060
=== modified file 'bzrlib/errors.py'
--- bzrlib/errors.py 2009-06-16 12:22:20 +0000
+++ bzrlib/errors.py 2009-06-17 08:35:26 +0000
@@ -2172,15 +2172,6 @@
2172 _fmt = "Cannot perform local-only commits on unbound branches."2172 _fmt = "Cannot perform local-only commits on unbound branches."
21732173
21742174
2175class InvalidProgressBarType(BzrError):
2176
2177 _fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
2178 " is not a supported type Select one of: %(valid_types)s")
2179
2180 def __init__(self, bar_type, valid_types):
2181 BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
2182
2183
2184class UnsupportedOperation(BzrError):2175class UnsupportedOperation(BzrError):
21852176
2186 _fmt = ("The method %(mname)s is not supported on"2177 _fmt = ("The method %(mname)s is not supported on"
21872178
=== modified file 'bzrlib/tests/blackbox/test_diff.py'
--- bzrlib/tests/blackbox/test_diff.py 2009-03-23 14:59:43 +0000
+++ bzrlib/tests/blackbox/test_diff.py 2009-06-17 08:35:26 +0000
@@ -360,18 +360,11 @@
360 # subprocess.py that we had to workaround).360 # subprocess.py that we had to workaround).
361 # However, if 'diff' may not be available361 # However, if 'diff' may not be available
362 self.make_example_branch()362 self.make_example_branch()
363 orig_progress = os.environ.get('BZR_PROGRESS_BAR')363 # this will be automatically restored by the base bzr test class
364 try:364 os.environ['BZR_PROGRESS_BAR'] = 'none'
365 os.environ['BZR_PROGRESS_BAR'] = 'none'365 out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
366 out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',366 universal_newlines=True,
367 universal_newlines=True,367 retcode=None)
368 retcode=None)
369 finally:
370 if orig_progress is None:
371 del os.environ['BZR_PROGRESS_BAR']
372 else:
373 os.environ['BZR_PROGRESS_BAR'] = orig_progress
374
375 if 'Diff is not installed on this machine' in err:368 if 'Diff is not installed on this machine' in err:
376 raise TestSkipped("No external 'diff' is available")369 raise TestSkipped("No external 'diff' is available")
377 self.assertEqual('', err)370 self.assertEqual('', err)
378371
=== modified file 'bzrlib/tests/test_ui.py'
--- bzrlib/tests/test_ui.py 2009-06-10 03:56:49 +0000
+++ bzrlib/tests/test_ui.py 2009-06-17 08:35:26 +0000
@@ -39,6 +39,7 @@
39 SilentUIFactory,39 SilentUIFactory,
40 )40 )
41from bzrlib.ui.text import (41from bzrlib.ui.text import (
42 NullProgressView,
42 TextProgressView,43 TextProgressView,
43 TextUIFactory,44 TextUIFactory,
44 )45 )
@@ -103,6 +104,25 @@
103 finally:104 finally:
104 pb.finished()105 pb.finished()
105106
107 def test_progress_construction(self):
108 """TextUIFactory constructs the right progress view.
109 """
110 os.environ['BZR_PROGRESS_BAR'] = 'none'
111 self.assertIsInstance(TextUIFactory()._progress_view,
112 NullProgressView)
113
114 os.environ['BZR_PROGRESS_BAR'] = 'text'
115 self.assertIsInstance(TextUIFactory()._progress_view,
116 TextProgressView)
117
118 os.environ['BZR_PROGRESS_BAR'] = 'text'
119 self.assertIsInstance(TextUIFactory()._progress_view,
120 TextProgressView)
121
122 del os.environ['BZR_PROGRESS_BAR']
123 self.assertIsInstance(TextUIFactory()._progress_view,
124 TextProgressView)
125
106 def test_progress_note(self):126 def test_progress_note(self):
107 stderr = StringIO()127 stderr = StringIO()
108 stdout = StringIO()128 stdout = StringIO()
109129
=== modified file 'bzrlib/ui/text.py'
--- bzrlib/ui/text.py 2009-04-10 19:37:20 +0000
+++ bzrlib/ui/text.py 2009-06-17 08:35:26 +0000
@@ -19,6 +19,7 @@
19"""Text UI, write output to the console.19"""Text UI, write output to the console.
20"""20"""
2121
22import os
22import sys23import sys
23import time24import time
24import warnings25import warnings
@@ -56,8 +57,8 @@
56 symbol_versioning.warn(symbol_versioning.deprecated_in((1, 11, 0))57 symbol_versioning.warn(symbol_versioning.deprecated_in((1, 11, 0))
57 % "bar_type parameter")58 % "bar_type parameter")
58 # paints progress, network activity, etc59 # paints progress, network activity, etc
59 self._progress_view = TextProgressView(self.stderr)60 self._progress_view = self._make_progress_view()
6061
61 def clear_term(self):62 def clear_term(self):
62 """Prepare the terminal for output.63 """Prepare the terminal for output.
6364
@@ -69,6 +70,12 @@
69 # to clear it. We might need to separately check for the case of70 # to clear it. We might need to separately check for the case of
70 self._progress_view.clear()71 self._progress_view.clear()
7172
73 def _make_progress_view(self):
74 if os.environ.get('BZR_PROGRESS_BAR') in ('text', None, ''):
75 return TextProgressView(self.stderr)
76 else:
77 return NullProgressView()
78
72 def note(self, msg):79 def note(self, msg):
73 """Write an already-formatted message, clearing the progress bar if necessary."""80 """Write an already-formatted message, clearing the progress bar if necessary."""
74 self.clear_term()81 self.clear_term()
@@ -80,7 +87,7 @@
80 This may update a progress bar, spinner, or similar display.87 This may update a progress bar, spinner, or similar display.
81 By default it does nothing.88 By default it does nothing.
82 """89 """
83 self._progress_view._show_transport_activity(transport,90 self._progress_view.show_transport_activity(transport,
84 direction, byte_count)91 direction, byte_count)
8592
86 def _progress_updated(self, task):93 def _progress_updated(self, task):
@@ -98,6 +105,19 @@
98 self._progress_view.clear()105 self._progress_view.clear()
99106
100107
108class NullProgressView(object):
109 """Soak up and ignore progress information."""
110
111 def clear(self):
112 pass
113
114 def show_progress(self, task):
115 pass
116
117 def show_transport_activity(self, transport, direction, byte_count):
118 pass
119
120
101class TextProgressView(object):121class TextProgressView(object):
102 """Display of progress bar and other information on a tty.122 """Display of progress bar and other information on a tty.
103123
@@ -216,7 +236,7 @@
216 self._last_repaint = now236 self._last_repaint = now
217 self._repaint()237 self._repaint()
218238
219 def _show_transport_activity(self, transport, direction, byte_count):239 def show_transport_activity(self, transport, direction, byte_count):
220 """Called by transports via the ui_factory, as they do IO.240 """Called by transports via the ui_factory, as they do IO.
221241
222 This may update a progress bar, spinner, or similar display.242 This may update a progress bar, spinner, or similar display.