Rev 3956: (mbp) further progress bar fixes in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jan 23 18:14:20 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3956
revision-id: pqm at pqm.ubuntu.com-20090123181416-tku4gdtorboy6d0y
parent: pqm at pqm.ubuntu.com-20090123103145-yvo3icrif75vkt20
parent: mbp at sourcefrog.net-20090123172552-uu2eh59t0azzvcq9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-01-23 18:14:16 +0000
message:
  (mbp) further progress bar fixes
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
  bzrlib/tests/test_progress.py  test_progress.py-20060308160359-978c397bc79b7fda
  bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
  bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
  bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
    ------------------------------------------------------------
    revno: 3948.2.8
    revision-id: mbp at sourcefrog.net-20090123172552-uu2eh59t0azzvcq9
    parent: mbp at sourcefrog.net-20090122214649-awlvm833pao0t1wp
    parent: pqm at pqm.ubuntu.com-20090123103145-yvo3icrif75vkt20
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Fri 2009-01-23 15:25:52 -0200
    message:
      merge trunk
    added:
      bzrlib/tests/branch_implementations/test_dotted_revno_to_revision_id.py test_dotted_revno_to-20090121014844-6x7d9jtri5sspg1o-1
      bzrlib/tests/branch_implementations/test_revision_id_to_dotted_revno.py test_revision_id_to_-20090122052032-g3czslif6sdqfkh3-1
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/revisionspec.py         revisionspec.py-20050907152633-17567659fd5c0ddb
      bzrlib/tests/branch_implementations/__init__.py __init__.py-20060123013057-b12a52c3f361daf4
      bzrlib/tests/test_knit.py      test_knit.py-20051212171302-95d4c00dd5f11f2b
      bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
      bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
      bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
    ------------------------------------------------------------
    revno: 3948.2.7
    revision-id: mbp at sourcefrog.net-20090122214649-awlvm833pao0t1wp
    parent: mbp at sourcefrog.net-20090121060117-4c3xrje8jahq70uu
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Thu 2009-01-22 19:46:49 -0200
    message:
      pep8
    modified:
      bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
    ------------------------------------------------------------
    revno: 3948.2.6
    revision-id: mbp at sourcefrog.net-20090121060117-4c3xrje8jahq70uu
    parent: mbp at sourcefrog.net-20090121054918-174smoskf8srdm41
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Wed 2009-01-21 04:01:17 -0200
    message:
      ProgressBarStack is deprecated
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
      bzrlib/tests/test_progress.py  test_progress.py-20060308160359-978c397bc79b7fda
      bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
    ------------------------------------------------------------
    revno: 3948.2.5
    revision-id: mbp at sourcefrog.net-20090121054918-174smoskf8srdm41
    parent: mbp at sourcefrog.net-20090121054258-cyngfg4gdv4tmqm1
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Wed 2009-01-21 03:49:18 -0200
    message:
      rename to _progress_all_finished
    modified:
      bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
      bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
    ------------------------------------------------------------
    revno: 3948.2.4
    revision-id: mbp at sourcefrog.net-20090121054258-cyngfg4gdv4tmqm1
    parent: mbp at sourcefrog.net-20090121053816-b2eua3hvawjhguzk
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Wed 2009-01-21 03:42:58 -0200
    message:
      Remove some obsolete progress docstring
    modified:
      bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
    ------------------------------------------------------------
    revno: 3948.2.3
    revision-id: mbp at sourcefrog.net-20090121053816-b2eua3hvawjhguzk
    parent: mbp at sourcefrog.net-20090121053044-mhynfsubozjh9wol
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Wed 2009-01-21 03:38:16 -0200
    message:
      Make the interface from ProgressTask to ui more private
    modified:
      bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
      bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
      bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
    ------------------------------------------------------------
    revno: 3948.2.2
    revision-id: mbp at sourcefrog.net-20090121053044-mhynfsubozjh9wol
    parent: mbp at sourcefrog.net-20090121050132-8j59ox99p84hiz51
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Wed 2009-01-21 03:30:44 -0200
    message:
      Corrections to finishing progress bars
    modified:
      bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
      bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
      bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
    ------------------------------------------------------------
    revno: 3948.2.1
    revision-id: mbp at sourcefrog.net-20090121050132-8j59ox99p84hiz51
    parent: pqm at pqm.ubuntu.com-20090120044335-pwr2rshr1yu6vzti
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: progress
    timestamp: Wed 2009-01-21 03:01:32 -0200
    message:
      Add ProgressTask repr
    modified:
      bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
=== modified file 'NEWS'
--- a/NEWS	2009-01-23 07:42:35 +0000
+++ b/NEWS	2009-01-23 17:25:52 +0000
@@ -73,6 +73,9 @@
 
   API CHANGES:
 
+    * ``ProgressBarStack`` is deprecated; instead use
+      ``ui_factory.nested_progress_bar`` to create new progress bars.
+
   TESTING:
 
   INTERNALS:

=== modified file 'bzrlib/progress.py'
--- a/bzrlib/progress.py	2009-01-16 02:43:37 +0000
+++ b/bzrlib/progress.py	2009-01-21 06:01:17 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2008 Canonical Ltd
+# Copyright (C) 2005, 2006, 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,13 +18,7 @@
 """Progress indicators.
 
 The usual way to use this is via bzrlib.ui.ui_factory.nested_progress_bar which
-will maintain a ProgressBarStack for you.
-
-For direct use, the factory ProgressBar will return an auto-detected progress
-bar that should match your terminal type. You can manually create a
-ProgressBarStack too if you need multiple levels of cooperating progress bars.
-Note that bzrlib's internal functions use the ui module, so if you are using
-bzrlib it really is best to use bzrlib.ui.ui_factory.
+will manage a conceptual stack of nested activities.
 """
 
 
@@ -41,6 +35,10 @@
     ui,
     )
 from bzrlib.trace import mutter
+from bzrlib.symbol_versioning import (
+    deprecated_in,
+    deprecated_method,
+    )
 
 
 def _supports_progress(f):
@@ -84,18 +82,25 @@
         self.show_count = True
         self.show_bar = True
 
+    def __repr__(self):
+        return '%s(%r/%r, msg=%r)' % (
+            self.__class__.__name__,
+            self.current_cnt,
+            self.total_cnt,
+            self.msg)
+
     def update(self, msg, current_cnt=None, total_cnt=None):
         self.msg = msg
         self.current_cnt = current_cnt
         if total_cnt:
             self.total_cnt = total_cnt
-        self.ui_factory.show_progress(self)
+        self.ui_factory._progress_updated(self)
 
     def tick(self):
         self.update(self.msg)
 
     def finished(self):
-        self.ui_factory.progress_finished(self)
+        self.ui_factory._progress_finished(self)
 
     def make_sub_task(self):
         return ProgressTask(self, self.ui_factory)
@@ -152,8 +157,13 @@
 
 
 class ProgressBarStack(object):
-    """A stack of progress bars."""
+    """A stack of progress bars.
+    
+    This class is deprecated: instead, ask the ui factory for a new progress
+    task and finish it when it's done.
+    """
 
+    @deprecated_method(deprecated_in((1, 12, 0)))
     def __init__(self,
                  to_file=None,
                  show_pct=False,

=== modified file 'bzrlib/tests/test_progress.py'
--- a/bzrlib/tests/test_progress.py	2008-02-13 03:30:01 +0000
+++ b/bzrlib/tests/test_progress.py	2009-01-21 06:01:17 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007 Canonical Ltd
+# Copyright (C) 2006, 2007, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,6 +27,9 @@
         InstrumentedProgress,
         )
 from bzrlib.tests import TestCase
+from bzrlib.symbol_versioning import (
+    deprecated_in,
+    )
 
 
 class FakeStack:
@@ -106,7 +109,10 @@
         self.check_stack(DummyProgress, DummyProgress)
 
     def check_stack(self, parent_class, child_class):
-        stack = ProgressBarStack(klass=parent_class, to_file=StringIO())
+        stack = self.applyDeprecated(
+            deprecated_in((1, 12, 0)),
+            ProgressBarStack,
+            klass=parent_class, to_file=StringIO())
         parent = stack.get_nested()
         try:
             self.assertIs(parent.__class__, parent_class)
@@ -212,7 +218,10 @@
 
         self.addCleanup(reset)
 
-        stack = ProgressBarStack(to_file=outf)
+        stack = self.applyDeprecated(
+            deprecated_in((1, 12, 0)),
+            ProgressBarStack,
+            to_file=outf)
         pb = stack.get_nested()
         pb.start_time -= 1 # Make sure it is ready to write
         pb.width = 20 # And it is of reasonable size

=== modified file 'bzrlib/tests/test_ui.py'
--- a/bzrlib/tests/test_ui.py	2009-01-15 06:44:09 +0000
+++ b/bzrlib/tests/test_ui.py	2009-01-21 06:01:17 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2008 Canonical Ltd
+# Copyright (C) 2005, 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,6 +29,9 @@
     ProgressBarStack,
     TTYProgressBar,
     )
+from bzrlib.symbol_versioning import (
+    deprecated_in,
+    )
 from bzrlib.tests import (
     TestCase,
     TestUIFactory,
@@ -144,9 +147,12 @@
         ui = TextUIFactory(None, None, None)
         pb1 = ui.nested_progress_bar()
         pb2 = ui.nested_progress_bar()
-        # We no longer warn about finishing unnested progress bars.
+        # You do get a warning if the outermost progress bar wasn't finished
+        # first - it's not clear if this is really useful or if it should just
+        # become orphaned -- mbp 20090120
         warnings, _ = self.callCatchWarnings(pb1.finished)
-        self.assertEqual(len(warnings), 0)
+        if len(warnings) != 1:
+            self.fail("unexpected warnings: %r" % (warnings,))
         pb2.finished()
         pb1.finished()
 
@@ -156,7 +162,10 @@
         stderr = StringIO()
         stdout = StringIO()
         # make a stack, which accepts parameters like a pb.
-        stack = ProgressBarStack(to_file=stderr, to_messages_file=stdout)
+        stack = self.applyDeprecated(
+            deprecated_in((1, 12, 0)),
+            ProgressBarStack,
+            to_file=stderr, to_messages_file=stdout)
         # but is not one
         self.assertFalse(getattr(stack, 'note', False))
         pb1 = stack.get_nested()

=== modified file 'bzrlib/ui/__init__.py'
--- a/bzrlib/ui/__init__.py	2009-01-22 11:20:03 +0000
+++ b/bzrlib/ui/__init__.py	2009-01-23 17:25:52 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -81,18 +81,37 @@
         self._task_stack.append(t)
         return t
 
-    def progress_finished(self, task):
-        if task != self._task_stack[-1]:
-            warnings.warn("%r is not currently active" % (task,))
+    def _progress_finished(self, task):
+        """Called by the ProgressTask when it finishes"""
+        if not self._task_stack:
+            warnings.warn("%r finished but nothing is active"
+                % (task,))
+        elif task != self._task_stack[-1]:
+            warnings.warn("%r is not the active task %r" 
+                % (task, self._task_stack[-1]))
         else:
             del self._task_stack[-1]
+        if not self._task_stack:
+            self._progress_all_finished()
+
+    def _progress_all_finished(self):
+        """Called when the top-level progress task finished"""
+        pass
+
+    def _progress_updated(self, task):
+        """Called by the ProgressTask when it changes.
+        
+        Should be specialized to draw the progress.
+        """
+        pass
 
     def clear_term(self):
         """Prepare the terminal for output.
 
         This will, for example, clear text progress bars, and leave the
-        cursor at the leftmost position."""
-        raise NotImplementedError(self.clear_term)
+        cursor at the leftmost position.
+        """
+        pass
 
     def get_boolean(self, prompt):
         """Get a boolean question answered from the user. 
@@ -178,15 +197,6 @@
         """Write an already-formatted message."""
         self.stdout.write(msg + '\n')
 
-    def clear_term(self):
-        pass
-
-    def show_progress(self, task):
-        pass
-
-    def progress_finished(self, task):
-        pass
-
 
 class SilentUIFactory(CLIUIFactory):
     """A UI Factory which never prints anything.

=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py	2008-12-16 07:56:29 +0000
+++ b/bzrlib/ui/text.py	2009-01-21 05:49:18 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2008 Canonical Ltd
+# Copyright (C) 2005, 2008, 2009 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
 
 import sys
 import time
+import warnings
 
 from bzrlib.lazy_import import lazy_import
 lazy_import(globals(), """
@@ -87,16 +88,16 @@
         """
         self._progress_view.show_transport_activity(byte_count)
 
-    def show_progress(self, task):
+    def _progress_updated(self, task):
         """A task has been updated and wants to be displayed.
         """
+        if task != self._task_stack[-1]:
+            warnings.warn("%r is not the top progress task %r" %
+                (task, self._task_stack[-1]))
         self._progress_view.show_progress(task)
 
-    def progress_finished(self, task):
-        CLIUIFactory.progress_finished(self, task)
-        if not self._task_stack:
-            # finished top-level task
-            self._progress_view.clear()
+    def _progress_all_finished(self):
+        self._progress_view.clear()
 
 
 class TextProgressView(object):
@@ -109,6 +110,9 @@
     task wants to be painted.
 
     Transports feed data to this through the ui_factory object.
+
+    The Progress views can comprise a tree with _parent_task pointers, but
+    this only prints the stack from the nominated current task up to the root.
     """
 
     def __init__(self, term_file):




More information about the bazaar-commits mailing list