Rev 4715: (mbp) deprecate ProgressTask.note in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Sep 24 10:45:26 BST 2009


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

------------------------------------------------------------
revno: 4715 [merge]
revision-id: pqm at pqm.ubuntu.com-20090924094523-nsz6mp3qwor3xpp3
parent: pqm at pqm.ubuntu.com-20090924080924-sbuqpuejjchpg2ht
parent: mbp at sourcefrog.net-20090924085652-e61iyfilrq82s252
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-09-24 10:45:23 +0100
message:
  (mbp) deprecate ProgressTask.note
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
  bzrlib/reconcile.py            reweave_inventory.py-20051108164726-1e5e0934febac06e
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
  bzrlib/upgrade.py              history2weaves.py-20050818063535-e7d319791c19a8b2
=== modified file 'NEWS'
--- a/NEWS	2009-09-24 06:53:43 +0000
+++ b/NEWS	2009-09-24 09:45:23 +0000
@@ -126,6 +126,9 @@
 API Changes
 ***********
 
+* ``ProgressTask.note`` is deprecated.
+  (Martin Pool)
+
 * ``bzrlib.user_encoding`` has been removed; use
   ``bzrlib.osutils.get_user_encoding`` instead.  (Martin Pool)
 

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2009-09-24 04:10:39 +0000
+++ b/bzrlib/bzrdir.py	2009-09-24 09:45:23 +0000
@@ -584,8 +584,7 @@
             # permissions as the .bzr directory (probably a bug in copy_tree)
             old_path = self.root_transport.abspath('.bzr')
             new_path = self.root_transport.abspath('backup.bzr')
-            pb.note('making backup of %s' % (old_path,))
-            pb.note('  to %s' % (new_path,))
+            ui.ui_factory.note('making backup of %s\n  to %s' % (old_path, new_path,))
             self.root_transport.copy_tree('.bzr', 'backup.bzr')
             return (old_path, new_path)
         finally:
@@ -2611,14 +2610,14 @@
         """See Converter.convert()."""
         self.bzrdir = to_convert
         self.pb = pb
-        self.pb.note('starting upgrade from format 4 to 5')
+        ui.ui_factory.note('starting upgrade from format 4 to 5')
         if isinstance(self.bzrdir.transport, local.LocalTransport):
             self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
         self._convert_to_weaves()
         return BzrDir.open(self.bzrdir.root_transport.base)
 
     def _convert_to_weaves(self):
-        self.pb.note('note: upgrade may be faster if all store files are ungzipped first')
+        ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
         try:
             # TODO permissions
             stat = self.bzrdir.transport.stat('weaves')
@@ -2652,10 +2651,10 @@
         self.pb.clear()
         self._write_all_weaves()
         self._write_all_revs()
-        self.pb.note('upgraded to weaves:')
-        self.pb.note('  %6d revisions and inventories', len(self.revisions))
-        self.pb.note('  %6d revisions not present', len(self.absent_revisions))
-        self.pb.note('  %6d texts', self.text_count)
+        ui.ui_factory.note('upgraded to weaves:')
+        ui.ui_factory.note('  %6d revisions and inventories' % len(self.revisions))
+        ui.ui_factory.note('  %6d revisions not present' % len(self.absent_revisions))
+        ui.ui_factory.note('  %6d texts' % self.text_count)
         self._cleanup_spare_files_after_format4()
         self.branch._transport.put_bytes(
             'branch-format',
@@ -2729,8 +2728,8 @@
                        len(self.known_revisions))
         if not self.branch.repository.has_revision(rev_id):
             self.pb.clear()
-            self.pb.note('revision {%s} not present in branch; '
-                         'will be converted as a ghost',
+            ui.ui_factory.note('revision {%s} not present in branch; '
+                         'will be converted as a ghost' %
                          rev_id)
             self.absent_revisions.add(rev_id)
         else:
@@ -2863,7 +2862,7 @@
         """See Converter.convert()."""
         self.bzrdir = to_convert
         self.pb = pb
-        self.pb.note('starting upgrade from format 5 to 6')
+        ui.ui_factory.note('starting upgrade from format 5 to 6')
         self._convert_to_prefixed()
         return BzrDir.open(self.bzrdir.root_transport.base)
 
@@ -2871,7 +2870,7 @@
         from bzrlib.store import TransportStore
         self.bzrdir.transport.delete('branch-format')
         for store_name in ["weaves", "revision-store"]:
-            self.pb.note("adding prefixes to %s" % store_name)
+            ui.ui_factory.note("adding prefixes to %s" % store_name)
             store_transport = self.bzrdir.transport.clone(store_name)
             store = TransportStore(store_transport, prefixed=True)
             for urlfilename in store_transport.list_dir('.'):
@@ -2911,7 +2910,7 @@
         self.dir_mode = self.bzrdir._get_dir_mode()
         self.file_mode = self.bzrdir._get_file_mode()
 
-        self.pb.note('starting upgrade from format 6 to metadir')
+        ui.ui_factory.note('starting upgrade from format 6 to metadir')
         self.bzrdir.transport.put_bytes(
                 'branch-format',
                 "Converting to format 6",
@@ -2967,7 +2966,7 @@
         else:
             has_checkout = True
         if not has_checkout:
-            self.pb.note('No working tree.')
+            ui.ui_factory.note('No working tree.')
             # If some checkout files are there, we may as well get rid of them.
             for name, mandatory in checkout_files:
                 if name in bzrcontents:
@@ -3042,7 +3041,7 @@
         else:
             if not isinstance(repo._format, self.target_format.repository_format.__class__):
                 from bzrlib.repository import CopyConverter
-                self.pb.note('starting repository conversion')
+                ui.ui_factory.note('starting repository conversion')
                 converter = CopyConverter(self.target_format.repository_format)
                 converter.convert(repo, pb)
         try:

=== modified file 'bzrlib/progress.py'
--- a/bzrlib/progress.py	2009-08-04 11:40:59 +0000
+++ b/bzrlib/progress.py	2009-09-24 04:55:10 +0000
@@ -34,6 +34,7 @@
 from bzrlib.symbol_versioning import (
     deprecated_function,
     deprecated_in,
+    deprecated_method,
     )
 
 
@@ -156,16 +157,27 @@
                 own_fraction = 0.0
             return self._parent_task._overall_completion_fraction(own_fraction)
 
+    @deprecated_method(deprecated_in((2, 1, 0)))
     def note(self, fmt_string, *args):
-        """Record a note without disrupting the progress bar."""
-        # XXX: shouldn't be here; put it in mutter or the ui instead
+        """Record a note without disrupting the progress bar.
+        
+        Deprecated: use ui_factory.note() instead or bzrlib.trace.  Note that
+        ui_factory.note takes just one string as the argument, not a format
+        string and arguments.
+        """
         if args:
             self.ui_factory.note(fmt_string % args)
         else:
             self.ui_factory.note(fmt_string)
 
     def clear(self):
-        # XXX: shouldn't be here; put it in mutter or the ui instead
+        # TODO: deprecate this method; the model object shouldn't be concerned
+        # with whether it's shown or not.  Most callers use this because they
+        # want to write some different non-progress output to the screen, but
+        # they should probably instead use a stream that's synchronized with
+        # the progress output.  It may be there is a model-level use for
+        # saying "this task's not active at the moment" but I don't see it. --
+        # mbp 20090623
         if self.progress_view:
             self.progress_view.clear()
         else:

=== modified file 'bzrlib/reconcile.py'
--- a/bzrlib/reconcile.py	2009-07-31 22:48:55 +0000
+++ b/bzrlib/reconcile.py	2009-09-24 04:54:19 +0000
@@ -90,26 +90,25 @@
             # Nothing to check here
             self.fixed_branch_history = None
             return
-        self.pb.note('Reconciling branch %s',
-                     self.branch.base)
+        ui.ui_factory.note('Reconciling branch %s' % self.branch.base)
         branch_reconciler = self.branch.reconcile(thorough=True)
         self.fixed_branch_history = branch_reconciler.fixed_history
 
     def _reconcile_repository(self):
         self.repo = self.bzrdir.find_repository()
-        self.pb.note('Reconciling repository %s',
-                     self.repo.bzrdir.root_transport.base)
+        ui.ui_factory.note('Reconciling repository %s' %
+            self.repo.bzrdir.root_transport.base)
         self.pb.update("Reconciling repository", 0, 1)
         repo_reconciler = self.repo.reconcile(thorough=True)
         self.inconsistent_parents = repo_reconciler.inconsistent_parents
         self.garbage_inventories = repo_reconciler.garbage_inventories
         if repo_reconciler.aborted:
-            self.pb.note(
+            ui.ui_factory.note(
                 'Reconcile aborted: revision index has inconsistent parents.')
-            self.pb.note(
+            ui.ui_factory.note(
                 'Run "bzr check" for more details.')
         else:
-            self.pb.note('Reconciliation complete.')
+            ui.ui_factory.note('Reconciliation complete.')
 
 
 class BranchReconciler(object):
@@ -151,13 +150,13 @@
             # set_revision_history, as this will regenerate it again.
             # Not really worth a whole BranchReconciler class just for this,
             # though.
-            self.pb.note('Fixing last revision info %s => %s',
-                         last_revno, len(real_history))
+            ui.ui_factory.note('Fixing last revision info %s => %s' % (
+                 last_revno, len(real_history)))
             self.branch.set_last_revision_info(len(real_history),
                                                last_revision_id)
         else:
             self.fixed_history = False
-            self.pb.note('revision_history ok.')
+            ui.ui_factory.note('revision_history ok.')
 
 
 class RepoReconciler(object):
@@ -238,11 +237,11 @@
         # (no garbage inventories or we are not doing a thorough check)
         if (not self.inconsistent_parents and
             (not self.garbage_inventories or not self.thorough)):
-            self.pb.note('Inventory ok.')
+            ui.ui_factory.note('Inventory ok.')
             return
         self.pb.update('Backing up inventory', 0, 0)
         self.repo._backup_inventory()
-        self.pb.note('Backup inventory created.')
+        ui.ui_factory.note('Backup inventory created.')
         new_inventories = self.repo._temp_inventories()
 
         # we have topological order of revisions and non ghost parents ready.
@@ -261,7 +260,7 @@
         self.pb.update('Writing weave')
         self.repo._activate_new_inventory()
         self.inventory = None
-        self.pb.note('Inventory regenerated.')
+        ui.ui_factory.note('Inventory regenerated.')
 
     def _new_inv_parents(self, revision_key):
         """Lookup ghost-filtered parents for revision_key."""
@@ -368,11 +367,11 @@
         self._check_garbage_inventories()
         self.pb.update('Checking unused inventories', 1, 3)
         if not self.garbage_inventories:
-            self.pb.note('Inventory ok.')
+            ui.ui_factory.note('Inventory ok.')
             return
         self.pb.update('Backing up inventory', 0, 0)
         self.repo._backup_inventory()
-        self.pb.note('Backup Inventory created')
+        ui.ui_factory.note('Backup Inventory created')
         # asking for '' should never return a non-empty weave
         new_inventories = self.repo._temp_inventories()
         # we have topological order of revisions and non ghost parents ready.
@@ -392,7 +391,7 @@
         self.pb.update('Writing weave')
         self.repo._activate_new_inventory()
         self.inventory = None
-        self.pb.note('Inventory regenerated.')
+        ui.ui_factory.note('Inventory regenerated.')
 
     def _fix_text_parents(self):
         """Fix bad versionedfile parent entries.

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2009-09-07 03:35:06 +0000
+++ b/bzrlib/repository.py	2009-09-24 04:54:19 +0000
@@ -4084,7 +4084,7 @@
             converted.unlock()
         self.step('Deleting old repository content')
         self.repo_dir.transport.delete_tree('repository.backup')
-        self.pb.note('repository converted')
+        ui.ui_factory.note('repository converted')
 
     def step(self, message):
         """Update the pb by a step."""

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-09-22 04:25:05 +0000
+++ b/bzrlib/tests/__init__.py	2009-09-24 04:54:19 +0000
@@ -512,20 +512,20 @@
         return self._shortened_test_description(test)
 
     def report_error(self, test, err):
-        self.pb.note('ERROR: %s\n    %s\n',
+        ui.ui_factory.note('ERROR: %s\n    %s\n' % (
             self._test_description(test),
             err[1],
-            )
+            ))
 
     def report_failure(self, test, err):
-        self.pb.note('FAIL: %s\n    %s\n',
+        ui.ui_factory.note('FAIL: %s\n    %s\n' % (
             self._test_description(test),
             err[1],
-            )
+            ))
 
     def report_known_failure(self, test, err):
-        self.pb.note('XFAIL: %s\n%s\n',
-            self._test_description(test), err[1])
+        ui.ui_factory.note('XFAIL: %s\n%s\n' % (
+            self._test_description(test), err[1]))
 
     def report_skip(self, test, reason):
         pass

=== modified file 'bzrlib/tests/test_ui.py'
--- a/bzrlib/tests/test_ui.py	2009-08-03 05:54:52 +0000
+++ b/bzrlib/tests/test_ui.py	2009-09-24 08:56:52 +0000
@@ -158,7 +158,9 @@
             stdout=stdout)
         pb = ui_factory.nested_progress_bar()
         try:
-            result = pb.note('t')
+            result = self.applyDeprecated(deprecated_in((2, 1, 0)),
+                pb.note,
+                't')
             self.assertEqual(None, result)
             self.assertEqual("t\n", stdout.getvalue())
             # Since there was no update() call, there should be no clear() call
@@ -182,7 +184,8 @@
         try:
             # Create a progress update that isn't throttled
             pb.update('x', 1, 1)
-            result = pb.note('t')
+            result = self.applyDeprecated(deprecated_in((2, 1, 0)),
+                pb.note, 't')
             self.assertEqual(None, result)
             self.assertEqual("t\n", stdout.getvalue())
             # the exact contents will depend on the terminal width and we don't

=== modified file 'bzrlib/upgrade.py'
--- a/bzrlib/upgrade.py	2009-05-07 05:08:46 +0000
+++ b/bzrlib/upgrade.py	2009-06-23 09:17:21 +0000
@@ -46,8 +46,8 @@
             branch = self.bzrdir.open_branch()
             if branch.bzrdir.root_transport.base != \
                 self.bzrdir.root_transport.base:
-                self.pb.note("This is a checkout. The branch (%s) needs to be "
-                             "upgraded separately.",
+                ui.ui_factory.note("This is a checkout. The branch (%s) needs to be "
+                             "upgraded separately." %
                              branch.bzrdir.root_transport.base)
             del branch
         except (errors.NotBranchError, errors.IncompatibleRepositories):
@@ -72,12 +72,13 @@
             raise errors.BzrError("cannot upgrade from bzrdir format %s" %
                            self.bzrdir._format)
         self.bzrdir.check_conversion_target(format)
-        self.pb.note('starting upgrade of %s', self.transport.base)
+        ui.ui_factory.note('starting upgrade of %s' % self.transport.base)
+
         self.bzrdir.backup_bzrdir()
         while self.bzrdir.needs_format_conversion(format):
             converter = self.bzrdir._format.get_converter(format)
             self.bzrdir = converter.convert(self.bzrdir, self.pb)
-        self.pb.note("finished")
+        ui.ui_factory.note("finished")
 
 
 def upgrade(url, format=None):




More information about the bazaar-commits mailing list