Rev 5070: (mbp) fix bug 611127, clearing progress bars (Martin Pool) in file:///home/pqm/archives/thelove/bzr/2.2/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Aug 6 09:14:50 BST 2010


At file:///home/pqm/archives/thelove/bzr/2.2/

------------------------------------------------------------
revno: 5070 [merge]
revision-id: pqm at pqm.ubuntu.com-20100806081448-dd4f3e0zas1ixx1q
parent: pqm at pqm.ubuntu.com-20100802223250-8e5mmqli51pmseuy
parent: mbp at sourcefrog.net-20100805081806-4c4gjsiw9i3j0c3w
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Fri 2010-08-06 09:14:48 +0100
message:
  (mbp) fix bug 611127, clearing progress bars (Martin Pool)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_progress.py  test_progress.py-20060308160359-978c397bc79b7fda
  bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
=== modified file 'NEWS'
--- a/NEWS	2010-08-02 19:56:52 +0000
+++ b/NEWS	2010-08-05 08:18:06 +0000
@@ -5,11 +5,11 @@
 .. contents:: List of Releases
    :depth: 1
 
-bzr 2.2rc1
-##########
+bzr 2.2.0
+#########
 
 :Codename: ???
-:2.2rc1: NOT RELEASED YET
+:2.2.0: NOT RELEASED YET
 
 Compatibility Breaks
 ********************
@@ -48,7 +48,8 @@
 
 * Progress bars prefer to truncate the text message rather than the
   counters.  The spinner is shown between the network transfer indicator
-  and the progress message.  (Martin Pool)
+  and the progress message.  Progress bars are correctly cleared off when 
+  they finish.  (Martin Pool, #611127)
 
 * Recursive binding for checkouts is now detected by bzr. A clear error
   message is shown to the user. (Parth Malwankar, #405192)

=== modified file 'bzrlib/tests/test_progress.py'
--- a/bzrlib/tests/test_progress.py	2010-07-09 15:47:01 +0000
+++ b/bzrlib/tests/test_progress.py	2010-08-05 08:18:06 +0000
@@ -70,6 +70,21 @@
         task.total_cnt = total
         return task
 
+    def test_clear(self):
+        # <https://bugs.launchpad.net/bzr/+bug/611127> clear must actually
+        # send spaces to clear the line
+        out, view = self.make_view()
+        task = self.make_task(None, view, 'reticulating splines', 5, 20)
+        view.show_progress(task)
+        self.assertEqual(
+'\r/ reticulating splines 5/20                                                    \r'
+            , out.getvalue())
+        view.clear()
+        self.assertEqual(
+'\r/ reticulating splines 5/20                                                    \r'
+            + '\r' + 79 * ' ' + '\r',
+            out.getvalue())
+
     def test_render_progress_no_bar(self):
         """The default view now has a spinner but no bar."""
         out, view = self.make_view()

=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py	2010-07-09 15:47:01 +0000
+++ b/bzrlib/ui/text.py	2010-08-05 08:18:06 +0000
@@ -304,11 +304,15 @@
         # we need one extra space for terminals that wrap on last char
         w = osutils.terminal_width() 
         if w is None:
-            return w
+            return None
         else:
             return w - 1
 
     def _show_line(self, s):
+        # sys.stderr.write("progress %r\n" % s)
+        width = self._avail_width()
+        if width is not None:
+            s = '%-*.*s' % (width, width, s)
         self._term_file.write('\r' + s + '\r')
 
     def clear(self):




More information about the bazaar-commits mailing list