Rev 3016: bzrlib.progress.DotsTaskDisplay does not output anything if the current value has not changed. in http://people.ubuntu.com/~robertc/baz2.0/nested-pb
Robert Collins
robertc at robertcollins.net
Tue Nov 20 00:24:09 GMT 2007
At http://people.ubuntu.com/~robertc/baz2.0/nested-pb
------------------------------------------------------------
revno: 3016
revision-id:robertc at robertcollins.net-20071120002404-fwpku689n1oz7rdw
parent: robertc at robertcollins.net-20071120001527-sf6mn66s3z9g5eaa
committer: Robert Collins <robertc at robertcollins.net>
branch nick: pb.simplify
timestamp: Tue 2007-11-20 11:24:04 +1100
message:
bzrlib.progress.DotsTaskDisplay does not output anything if the current value has not changed.
modified:
bzrlib/progress.py progress.py-20050610070202-df9faaab791964c0
bzrlib/tests/test_progress.py test_progress.py-20060308160359-978c397bc79b7fda
=== modified file 'bzrlib/progress.py'
--- a/bzrlib/progress.py 2007-11-20 00:15:27 +0000
+++ b/bzrlib/progress.py 2007-11-20 00:24:04 +0000
@@ -290,6 +290,7 @@
TaskDisplay.__init__(self, task)
self._stream = stream
self._last_message = None
+ self._last_current = None
def task_changed(self):
# When the task changes, a dots display should output each message it
@@ -299,8 +300,10 @@
if message != self._last_message:
self._stream.write(message + ':')
self._last_message = message
- else:
+ self._last_current = self._task.current
+ elif self._task.current != self._last_current:
self._stream.write('.')
+ self._last_current = self._task.current
class SilentTaskDisplay(TaskDisplay):
=== modified file 'bzrlib/tests/test_progress.py'
--- a/bzrlib/tests/test_progress.py 2007-11-20 00:15:27 +0000
+++ b/bzrlib/tests/test_progress.py 2007-11-20 00:24:04 +0000
@@ -369,6 +369,18 @@
display.task_changed()
self.assertEqual('message:', output.getvalue())
+ def test_task_changed_no_change(self):
+ task = CountedTask('message')
+ output = StringIO()
+ display = DotsTaskDisplay(task, output)
+ # The first change will display the message
+ display.task_changed()
+ self.assertEqual('message:', output.getvalue())
+ # Calling task_changed when nothing has actually changed will output
+ # nothing.
+ display.task_changed()
+ self.assertEqual('message:', output.getvalue())
+
def test_task_changed_task_has_ticked(self):
task = CountedTask('message')
output = StringIO()
More information about the bazaar-commits
mailing list