Merge lp:~mbp/bzr/611127-2.2-progress into lp:bzr/2.2

Proposed by Martin Pool
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5070
Proposed branch: lp:~mbp/bzr/611127-2.2-progress
Merge into: lp:bzr/2.2
Diff against target: 75 lines (+25/-5)
3 files modified
NEWS (+5/-4)
bzrlib/tests/test_progress.py (+15/-0)
bzrlib/ui/text.py (+5/-1)
To merge this branch: bzr merge lp:~mbp/bzr/611127-2.2-progress
Reviewer Review Type Date Requested Status
Andrew Bennetts Approve
Review via email: mp+31824@code.launchpad.net

Commit message

fix bug 611127, clearing progress bars

Description of the change

Fix a regression with progress bars not being cleared off properly. This just restores this method pretty much to how it was in 2.1.

I would like to merge this before 2.2.0.

Fixes https://bugs.edge.launchpad.net/bzr/+bug/611127

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

+1

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

I suppose theoretically if _avail_width is None this could remember the width of the last uncleared message(s), but then terminals that can't report widths probably aren't used here anyway. Anyway, this seems like a clear and simple improvement, so +1.

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

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-08-02 19:56:52 +0000
3+++ NEWS 2010-08-05 08:31:42 +0000
4@@ -5,11 +5,11 @@
5 .. contents:: List of Releases
6 :depth: 1
7
8-bzr 2.2rc1
9-##########
10+bzr 2.2.0
11+#########
12
13 :Codename: ???
14-:2.2rc1: NOT RELEASED YET
15+:2.2.0: NOT RELEASED YET
16
17 Compatibility Breaks
18 ********************
19@@ -48,7 +48,8 @@
20
21 * Progress bars prefer to truncate the text message rather than the
22 counters. The spinner is shown between the network transfer indicator
23- and the progress message. (Martin Pool)
24+ and the progress message. Progress bars are correctly cleared off when
25+ they finish. (Martin Pool, #611127)
26
27 * Recursive binding for checkouts is now detected by bzr. A clear error
28 message is shown to the user. (Parth Malwankar, #405192)
29
30=== modified file 'bzrlib/tests/test_progress.py'
31--- bzrlib/tests/test_progress.py 2010-07-09 15:47:01 +0000
32+++ bzrlib/tests/test_progress.py 2010-08-05 08:31:42 +0000
33@@ -70,6 +70,21 @@
34 task.total_cnt = total
35 return task
36
37+ def test_clear(self):
38+ # <https://bugs.launchpad.net/bzr/+bug/611127> clear must actually
39+ # send spaces to clear the line
40+ out, view = self.make_view()
41+ task = self.make_task(None, view, 'reticulating splines', 5, 20)
42+ view.show_progress(task)
43+ self.assertEqual(
44+'\r/ reticulating splines 5/20 \r'
45+ , out.getvalue())
46+ view.clear()
47+ self.assertEqual(
48+'\r/ reticulating splines 5/20 \r'
49+ + '\r' + 79 * ' ' + '\r',
50+ out.getvalue())
51+
52 def test_render_progress_no_bar(self):
53 """The default view now has a spinner but no bar."""
54 out, view = self.make_view()
55
56=== modified file 'bzrlib/ui/text.py'
57--- bzrlib/ui/text.py 2010-07-09 15:47:01 +0000
58+++ bzrlib/ui/text.py 2010-08-05 08:31:42 +0000
59@@ -304,11 +304,15 @@
60 # we need one extra space for terminals that wrap on last char
61 w = osutils.terminal_width()
62 if w is None:
63- return w
64+ return None
65 else:
66 return w - 1
67
68 def _show_line(self, s):
69+ # sys.stderr.write("progress %r\n" % s)
70+ width = self._avail_width()
71+ if width is not None:
72+ s = '%-*.*s' % (width, width, s)
73 self._term_file.write('\r' + s + '\r')
74
75 def clear(self):

Subscribers

People subscribed via source and target branches