Merge lp:~mbp/bzr/progress into lp:bzr

Proposed by Martin Pool
Status: Merged
Approved by: Martin Pool
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~mbp/bzr/progress
Merge into: lp:bzr
Diff against target: 81 lines (+24/-1)
3 files modified
NEWS (+6/-0)
bzrlib/tests/test_progress.py (+13/-0)
bzrlib/ui/text.py (+5/-1)
To merge this branch: bzr merge lp:~mbp/bzr/progress
Reviewer Review Type Date Requested Status
Andrew Bennetts Approve
Review via email: mp+15997@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

This changes the progress bar to be just a spinner plus transport info and text. I think it looks better, and it allays complaints that the bar does not correspond to overall progress.

Revision history for this message
Andrew Bennetts (spiv) wrote :

Interesting that there was no test for the default progress showing a bar. Anyway, this patch seems fine. I'm sure we'll get plenty of feedback from people once its in trunk, hopefully positive! :)

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

There are tests for the default, that's why I need to poke in view.show_bar=True to make them keep passing.

lp:~mbp/bzr/progress updated
4890. By Canonical.com Patch Queue Manager <email address hidden>

(mbp) turn off progress bar; just show a spinner

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-12-10 21:49:20 +0000
+++ NEWS 2009-12-11 03:54:15 +0000
@@ -112,6 +112,12 @@
112 'file://localhost/' as well as 'file:///' URLs on POSIX. (Michael112 'file://localhost/' as well as 'file:///' URLs on POSIX. (Michael
113 Hudson)113 Hudson)
114114
115* The progress bar now shows only a spinner and per-operation counts,
116 not an overall progress bar. The previous bar was often not correlated
117 with real overall operation progress, either because the operations take
118 nonlinear time, or because at the start of the operation Bazaar couldn't
119 estimate how much work there was to do. (Martin Pool)
120
115Documentation121Documentation
116*************122*************
117123
118124
=== modified file 'bzrlib/tests/test_progress.py'
--- bzrlib/tests/test_progress.py 2009-06-19 07:28:41 +0000
+++ bzrlib/tests/test_progress.py 2009-12-11 03:54:15 +0000
@@ -70,9 +70,20 @@
70 task.total_cnt = total70 task.total_cnt = total
71 return task71 return task
7272
73 def test_render_progress_no_bar(self):
74 """The default view now has a spinner but no bar."""
75 out, view = self.make_view()
76 # view.enable_bar = False
77 task = self.make_task(None, view, 'reticulating splines', 5, 20)
78 view.show_progress(task)
79 self.assertEqual(
80'\r/ reticulating splines 5/20 \r'
81 , out.getvalue())
82
73 def test_render_progress_easy(self):83 def test_render_progress_easy(self):
74 """Just one task and one quarter done"""84 """Just one task and one quarter done"""
75 out, view = self.make_view()85 out, view = self.make_view()
86 view.enable_bar = True
76 task = self.make_task(None, view, 'reticulating splines', 5, 20)87 task = self.make_task(None, view, 'reticulating splines', 5, 20)
77 view.show_progress(task)88 view.show_progress(task)
78 self.assertEqual(89 self.assertEqual(
@@ -85,6 +96,7 @@
85 task = self.make_task(None, view, 'reticulating splines', 0, 2)96 task = self.make_task(None, view, 'reticulating splines', 0, 2)
86 task2 = self.make_task(task, view, 'stage2', 1, 2)97 task2 = self.make_task(task, view, 'stage2', 1, 2)
87 view.show_progress(task2)98 view.show_progress(task2)
99 view.enable_bar = True
88 # so we're in the first half of the main task, and half way through100 # so we're in the first half of the main task, and half way through
89 # that101 # that
90 self.assertEqual(102 self.assertEqual(
@@ -100,6 +112,7 @@
100 def test_render_progress_sub_nested(self):112 def test_render_progress_sub_nested(self):
101 """Intermediate tasks don't mess up calculation."""113 """Intermediate tasks don't mess up calculation."""
102 out, view = self.make_view()114 out, view = self.make_view()
115 view.enable_bar = True
103 task_a = ProgressTask(None, progress_view=view)116 task_a = ProgressTask(None, progress_view=view)
104 task_a.update('a', 0, 2)117 task_a.update('a', 0, 2)
105 task_b = ProgressTask(task_a, progress_view=view)118 task_b = ProgressTask(task_a, progress_view=view)
106119
=== modified file 'bzrlib/ui/text.py'
--- bzrlib/ui/text.py 2009-12-10 16:54:28 +0000
+++ bzrlib/ui/text.py 2009-12-11 03:54:15 +0000
@@ -261,6 +261,9 @@
261 self._total_byte_count = 0261 self._total_byte_count = 0
262 self._bytes_since_update = 0262 self._bytes_since_update = 0
263 self._fraction = 0263 self._fraction = 0
264 # force the progress bar to be off, as at the moment it doesn't
265 # correspond reliably to overall command progress
266 self.enable_bar = False
264267
265 def _show_line(self, s):268 def _show_line(self, s):
266 # sys.stderr.write("progress %r\n" % s)269 # sys.stderr.write("progress %r\n" % s)
@@ -276,7 +279,8 @@
276279
277 def _render_bar(self):280 def _render_bar(self):
278 # return a string for the progress bar itself281 # return a string for the progress bar itself
279 if (self._last_task is None) or self._last_task.show_bar:282 if self.enable_bar and (
283 (self._last_task is None) or self._last_task.show_bar):
280 # If there's no task object, we show space for the bar anyhow.284 # If there's no task object, we show space for the bar anyhow.
281 # That's because most invocations of bzr will end showing progress285 # That's because most invocations of bzr will end showing progress
282 # at some point, though perhaps only after doing some initial IO.286 # at some point, though perhaps only after doing some initial IO.