Rev 4610: (mbp) cleanup check_conversion_target and upgrade blackbox tests in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Aug 14 13:14:52 BST 2009


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

------------------------------------------------------------
revno: 4610 [merge]
revision-id: pqm at pqm.ubuntu.com-20090814121451-n3h9cp3c26mmpe9m
parent: pqm at pqm.ubuntu.com-20090814084522-m4bomm9pj2ne1kw1
parent: mbp at sourcefrog.net-20090814093757-dn7s5anq6b2druua
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-08-14 13:14:51 +0100
message:
  (mbp) cleanup check_conversion_target and upgrade blackbox tests
modified:
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/repofmt/groupcompress_repo.py repofmt.py-20080715094215-wp1qfvoo7093c8qr-1
  bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/blackbox/test_upgrade.py test_upgrade.py-20060120060132-b41e5ed2f886ad28
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2009-08-04 14:48:59 +0000
+++ b/bzrlib/bzrdir.py	2009-08-14 09:31:37 +0000
@@ -3039,7 +3039,8 @@
                       new is _mod_branch.BzrBranchFormat8):
                     branch_converter = _mod_branch.Converter7to8()
                 else:
-                    raise errors.BadConversionTarget("No converter", new)
+                    raise errors.BadConversionTarget("No converter", new,
+                        branch._format)
                 branch_converter.convert(branch)
                 branch = self.bzrdir.open_branch()
                 old = branch._format.__class__

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2009-07-14 21:07:36 +0000
+++ b/bzrlib/errors.py	2009-08-14 09:31:37 +0000
@@ -2006,12 +2006,14 @@
 
 class BadConversionTarget(BzrError):
 
-    _fmt = "Cannot convert to format %(format)s.  %(problem)s"
+    _fmt = "Cannot convert from format %(from_format)s to format %(format)s." \
+            "    %(problem)s"
 
-    def __init__(self, problem, format):
+    def __init__(self, problem, format, from_format=None):
         BzrError.__init__(self)
         self.problem = problem
         self.format = format
+        self.from_format = from_format or '(unspecified)'
 
 
 class NoDiffFound(BzrError):

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2009-08-14 04:45:57 +0000
+++ b/bzrlib/remote.py	2009-08-14 09:31:37 +0000
@@ -431,6 +431,10 @@
         self._supports_tree_reference = None
         self._rich_root_data = None
 
+    def __repr__(self):
+        return "%s(_network_name=%r)" % (self.__class__.__name__,
+            self._network_name)
+
     @property
     def fast_deltas(self):
         self._ensure_real()
@@ -565,11 +569,13 @@
     def check_conversion_target(self, target_format):
         if self.rich_root_data and not target_format.rich_root_data:
             raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
+                'Does not support rich root data.', target_format,
+                from_format=self)
         if (self.supports_tree_reference and
             not getattr(target_format, 'supports_tree_reference', False)):
             raise errors.BadConversionTarget(
-                'Does not support nested trees', target_format)
+                'Does not support nested trees', target_format,
+                from_format=self)
 
     def network_name(self):
         if self._network_name:

=== modified file 'bzrlib/repofmt/groupcompress_repo.py'
--- a/bzrlib/repofmt/groupcompress_repo.py	2009-08-13 08:59:02 +0000
+++ b/bzrlib/repofmt/groupcompress_repo.py	2009-08-14 09:37:57 +0000
@@ -1101,16 +1101,6 @@
         return ("Development repository format - rich roots, group compression"
             " and chk inventories")
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-        if (self.supports_tree_reference and 
-            not getattr(target_format, 'supports_tree_reference', False)):
-            raise errors.BadConversionTarget(
-                'Does not support nested trees', target_format)
-
-
 
 class RepositoryFormatCHK2(RepositoryFormatCHK1):
     """A CHK repository that uses the bencode revision serializer."""

=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py	2009-06-16 05:29:42 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2009-08-14 09:37:57 +0000
@@ -460,14 +460,6 @@
 
     _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-        if not getattr(target_format, 'supports_tree_reference', False):
-            raise errors.BadConversionTarget(
-                'Does not support nested trees', target_format)
-
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return "Bazaar Knit Repository Format 3 (bzr 0.15)\n"
@@ -509,11 +501,6 @@
 
     _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return 'Bazaar Knit Repository Format 4 (bzr 1.0)\n'

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2009-08-13 03:22:22 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2009-08-14 09:37:57 +0000
@@ -2563,14 +2563,6 @@
 
     _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-        if not getattr(target_format, 'supports_tree_reference', False):
-            raise errors.BadConversionTarget(
-                'Does not support nested trees', target_format)
-
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return "Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n"
@@ -2609,11 +2601,6 @@
 
     _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return ("Bazaar pack repository format 1 with rich root"
@@ -2695,11 +2682,6 @@
 
     _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
@@ -2746,11 +2728,6 @@
 
     _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
@@ -2826,11 +2803,6 @@
 
     _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return "Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n"
@@ -2872,14 +2844,6 @@
 
     _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
-    def check_conversion_target(self, target_format):
-        if not target_format.rich_root_data:
-            raise errors.BadConversionTarget(
-                'Does not support rich root data.', target_format)
-        if not getattr(target_format, 'supports_tree_reference', False):
-            raise errors.BadConversionTarget(
-                'Does not support nested trees', target_format)
-
     def get_format_string(self):
         """See RepositoryFormat.get_format_string()."""
         return ("Bazaar development format 2 with subtree support "

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2009-08-14 00:55:42 +0000
+++ b/bzrlib/repository.py	2009-08-14 09:37:57 +0000
@@ -3166,7 +3166,15 @@
         raise NotImplementedError(self.network_name)
 
     def check_conversion_target(self, target_format):
-        raise NotImplementedError(self.check_conversion_target)
+        if self.rich_root_data and not target_format.rich_root_data:
+            raise errors.BadConversionTarget(
+                'Does not support rich root data.', target_format,
+                from_format=self)
+        if (self.supports_tree_reference and 
+            not getattr(target_format, 'supports_tree_reference', False)):
+            raise errors.BadConversionTarget(
+                'Does not support nested trees', target_format,
+                from_format=self)
 
     def open(self, a_bzrdir, _found=False):
         """Return an instance of this format for the bzrdir a_bzrdir.

=== modified file 'bzrlib/tests/blackbox/test_upgrade.py'
--- a/bzrlib/tests/blackbox/test_upgrade.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_upgrade.py	2009-08-14 08:57:57 +0000
@@ -42,29 +42,35 @@
         self.old_format = bzrdir.BzrDirFormat.get_default_format()
         self.old_ui_factory = ui.ui_factory
         self.addCleanup(self.restoreDefaults)
-
         ui.ui_factory = TestUIFactory()
+
+    def restoreDefaults(self):
+        ui.ui_factory = self.old_ui_factory
+        bzrdir.BzrDirFormat._set_default_format(self.old_format)
+
+    def make_current_format_branch_and_checkout(self):
+        current_tree = self.make_branch_and_tree('current_format_branch',
+                                                 format='default')
+        current_tree.branch.create_checkout(
+            self.get_url('current_format_checkout'), lightweight=True)
+
+    def make_format_5_branch(self):
         # setup a format 5 branch we can upgrade from.
         self.make_branch_and_tree('format_5_branch',
                                   format=bzrdir.BzrDirFormat5())
 
-        current_tree = self.make_branch_and_tree('current_format_branch',
-                                                 format='default')
+    def make_metadir_weave_branch(self):
         self.make_branch_and_tree('metadir_weave_branch', format='metaweave')
-        current_tree.branch.create_checkout(
-            self.get_url('current_format_checkout'), lightweight=True)
-
-    def restoreDefaults(self):
-        ui.ui_factory = self.old_ui_factory
-        bzrdir.BzrDirFormat._set_default_format(self.old_format)
 
     def test_readonly_url_error(self):
+        self.make_format_5_branch()
         (out, err) = self.run_bzr(
             ['upgrade', self.get_readonly_url('format_5_branch')], retcode=3)
         self.assertEqual(out, "")
         self.assertEqual(err, "bzr: ERROR: Upgrade URL cannot work with readonly URLs.\n")
 
     def test_upgrade_up_to_date(self):
+        self.make_current_format_branch_and_checkout()
         # when up to date we should get a message to that effect
         (out, err) = self.run_bzr('upgrade current_format_branch', retcode=3)
         self.assertEqual("", out)
@@ -73,6 +79,7 @@
                              "recent format.\n", err)
 
     def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
+        self.make_current_format_branch_and_checkout()
         # when upgrading a checkout, the branch location and a suggestion
         # to upgrade it should be emitted even if the checkout is up to
         # date
@@ -100,6 +107,7 @@
 
     def test_upgrade_explicit_metaformat(self):
         # users can force an upgrade to metadir format.
+        self.make_format_5_branch()
         url = get_transport(self.get_url('format_5_branch')).base
         # check --format takes effect
         bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
@@ -122,6 +130,7 @@
     def test_upgrade_explicit_knit(self):
         # users can force an upgrade to knit format from a metadir weave
         # branch
+        self.make_metadir_weave_branch()
         url = get_transport(self.get_url('metadir_weave_branch')).base
         # check --format takes effect
         bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())




More information about the bazaar-commits mailing list