Rev 5693: (jelmer) Add RepositoryFormat.is_deprecated(). (Jelmer Vernooij) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Mar 3 03:53:32 UTC 2011


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

------------------------------------------------------------
revno: 5693 [merge]
revision-id: pqm at pqm.ubuntu.com-20110303035329-o7jglt1fy4cwtw1f
parent: pqm at pqm.ubuntu.com-20110302185902-f0qc7uyy82j785q3
parent: jelmer at samba.org-20110303022857-pe8967n481mlengo
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-03-03 03:53:29 +0000
message:
  (jelmer) Add RepositoryFormat.is_deprecated(). (Jelmer Vernooij)
modified:
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/registry.py             lazy_factory.py-20060809213415-2gfvqadtvdn0phtg-1
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/repofmt/weaverepo.py    presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/blackbox/test_exceptions.py test_exceptions.py-20060604211237-yi2cxg0ose3xk4id-1
  bzrlib/tests/blackbox/test_upgrade.py test_upgrade.py-20060120060132-b41e5ed2f886ad28
  bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2011-02-24 16:13:39 +0000
+++ b/bzrlib/bzrdir.py	2011-03-03 02:28:57 +0000
@@ -37,7 +37,6 @@
 
 import bzrlib
 from bzrlib import (
-    branch,
     config,
     controldir,
     errors,
@@ -2050,7 +2049,8 @@
             if target_branch is None:
                 if do_upgrade:
                     # TODO: bad monkey, hard-coded formats...
-                    new_branch_format = branch.BzrBranchFormat7()
+                    from bzrlib.branch import BzrBranchFormat7
+                    new_branch_format = BzrBranchFormat7()
             else:
                 new_branch_format = target_branch._format
                 if not new_branch_format.supports_stacking():

=== modified file 'bzrlib/registry.py'
--- a/bzrlib/registry.py	2011-02-24 16:21:50 +0000
+++ b/bzrlib/registry.py	2011-03-03 02:28:57 +0000
@@ -275,6 +275,11 @@
             self._other_registry.register_lazy(key, module_name, member_name,
                 help=help, info=info, override_existing=override_existing)
 
+    def remove(self, key):
+        Registry.remove(self, key)
+        if self._other_registry is not None:
+            self._other_registry.remove(key)
+
     def get(self, format_string):
         r = Registry.get(self, format_string)
         if callable(r):

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2011-02-21 15:09:19 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2011-02-21 23:31:07 +0000
@@ -2303,11 +2303,6 @@
         self._reconcile_fixes_text_parents = True
         self._reconcile_backsup_inventory = False
 
-    def _warn_if_deprecated(self, branch=None):
-        # This class isn't deprecated, but one sub-format is
-        if isinstance(self._format, RepositoryFormatKnitPack5RichRootBroken):
-            super(KnitPackRepository, self)._warn_if_deprecated(branch)
-
     def _abort_write_group(self):
         self.revisions._index._key_dependencies.clear()
         self._pack_collection._abort_write_group()
@@ -2838,6 +2833,9 @@
         return ("Packs 5 rich-root (adds stacking support, requires bzr 1.6)"
                 " (deprecated)")
 
+    def is_deprecated(self):
+        return True
+
 
 class RepositoryFormatKnitPack6(RepositoryFormatPack):
     """A repository with stacking and btree indexes,

=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py	2011-02-24 16:39:34 +0000
+++ b/bzrlib/repofmt/weaverepo.py	2011-03-03 02:28:57 +0000
@@ -329,6 +329,9 @@
         result.chk_bytes = None
         return result
 
+    def is_deprecated(self):
+        return True
+
 
 class RepositoryFormat4(PreSplitOutRepositoryFormat):
     """Bzr repository format 4.
@@ -573,6 +576,9 @@
         result._transport = repo_transport
         return result
 
+    def is_deprecated(self):
+        return True
+
 
 class TextVersionedFiles(VersionedFiles):
     """Just-a-bunch-of-files based VersionedFile stores."""

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2011-02-24 16:39:34 +0000
+++ b/bzrlib/repository.py	2011-03-03 02:28:57 +0000
@@ -2733,6 +2733,8 @@
         return result
 
     def _warn_if_deprecated(self, branch=None):
+        if not self._format.is_deprecated():
+            return
         global _deprecation_warning_done
         if _deprecation_warning_done:
             return
@@ -3118,6 +3120,14 @@
         """
         return True
 
+    def is_deprecated(self):
+        """Is this format deprecated?
+
+        Deprecated formats may trigger a user-visible warning recommending
+        the user to upgrade. They are still fully supported.
+        """
+        return False
+
     def network_name(self):
         """A simple byte string uniquely identifying this format for RPC calls.
 

=== modified file 'bzrlib/tests/blackbox/test_exceptions.py'
--- a/bzrlib/tests/blackbox/test_exceptions.py	2011-01-12 01:01:53 +0000
+++ b/bzrlib/tests/blackbox/test_exceptions.py	2011-03-03 02:28:57 +0000
@@ -21,11 +21,13 @@
 from bzrlib import (
     bzrdir,
     config,
+    controldir,
     errors,
     osutils,
     repository,
     tests,
     )
+from bzrlib.repofmt.groupcompress_repo import RepositoryFormat2a
 
 from bzrlib.tests import TestCase
 
@@ -56,6 +58,16 @@
         out = self.run_bzr_error([error_re], ['st',u'-\xe4'])
 
 
+class TestObsoleteRepoFormat(RepositoryFormat2a):
+
+    @classmethod
+    def get_format_string(cls):
+        return "Test Obsolete Repository Format"
+
+    def is_deprecated(self):
+        return True
+
+
 class TestDeprecationWarning(tests.TestCaseWithTransport):
     """The deprecation warning is controlled via a global variable:
     repository._deprecation_warning_done. As such, it can be emitted only once
@@ -67,6 +79,16 @@
 
     def setUp(self):
         super(TestDeprecationWarning, self).setUp()
+        self.addCleanup(repository.format_registry.remove,
+            TestObsoleteRepoFormat)
+        repository.format_registry.register(TestObsoleteRepoFormat)
+        self.addCleanup(controldir.format_registry.remove, "testobsolete")
+        bzrdir.register_metadir(controldir.format_registry, "testobsolete",
+            "bzrlib.tests.blackbox.test_exceptions.TestObsoleteRepoFormat",
+            branch_format='bzrlib.branch.BzrBranchFormat7',
+            tree_format='bzrlib.workingtree.WorkingTreeFormat6',
+            deprecated=True,
+            help='Same as 2a, but with an obsolete repo format.')
         self.disable_deprecation_warning()
 
     def enable_deprecation_warning(self, repo=None):
@@ -79,7 +101,8 @@
 
     def make_obsolete_repo(self, path):
         # We don't want the deprecation raising during the repo creation
-        tree = self.make_branch_and_tree(path, format=bzrdir.BzrDirFormat5())
+        format = controldir.format_registry.make_bzrdir("testobsolete")
+        tree = self.make_branch_and_tree(path, format=format)
         return tree
 
     def check_warning(self, present):

=== modified file 'bzrlib/tests/blackbox/test_upgrade.py'
--- a/bzrlib/tests/blackbox/test_upgrade.py	2011-01-27 15:58:36 +0000
+++ b/bzrlib/tests/blackbox/test_upgrade.py	2011-02-21 23:31:07 +0000
@@ -21,7 +21,6 @@
 from bzrlib import (
     bzrdir,
     controldir,
-    transport,
     )
 from bzrlib.tests import (
     features,

=== modified file 'bzrlib/tests/per_repository/test_repository.py'
--- a/bzrlib/tests/per_repository/test_repository.py	2011-02-24 16:13:39 +0000
+++ b/bzrlib/tests/per_repository/test_repository.py	2011-03-03 02:28:57 +0000
@@ -88,6 +88,14 @@
     def test_attribute_format_pack_compresses(self):
         self.assertFormatAttribute('pack_compresses', (True, False))
 
+    def test_format_is_deprecated(self):
+        repo = self.make_repository('repo')
+        self.assertSubset([repo._format.is_deprecated()], (True, False))
+
+    def test_format_is_supported(self):
+        repo = self.make_repository('repo')
+        self.assertSubset([repo._format.is_supported()], (True, False))
+
     def test_attribute_inventories_store(self):
         """Test the existence of the inventories attribute."""
         tree = self.make_branch_and_tree('tree')

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-02-26 15:39:49 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-03-03 02:28:57 +0000
@@ -168,6 +168,10 @@
   (``bzrlib.repository.format_registry``) rather than using the class
   methods on ``RepositoryFormat``. (Jelmer Vernooij)
 
+* Repository formats have a new method ``is_deprecated`` that
+  implementations can override to return True to trigger a deprecation
+  warning. (Jelmer Vernooij)
+
 * The ``revision_id`` parameter of
   ``Repository.search_missing_revision_ids`` and
   ``InterRepository.search_missing_revision_ids`` is deprecated.  It is




More information about the bazaar-commits mailing list