Rev 3605: (mbp) test upgrade with stacking in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Aug 5 07:21:49 BST 2008


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

------------------------------------------------------------
revno: 3605
revision-id: pqm at pqm.ubuntu.com-20080805062143-idm263sn4iw3cmkw
parent: pqm at pqm.ubuntu.com-20080805044416-k5w5uuy3l785e7cm
parent: mbp at sourcefrog.net-20080804075541-jka7smxkix7ozvb1
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2008-08-05 07:21:43 +0100
message:
  (mbp) test upgrade with stacking
added:
  bzrlib/tests/test_upgrade_stacked.py test_upgrade_stacked-20080804072225-jd13yami19nskns5-1
modified:
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
  bzrlib/upgrade.py              history2weaves.py-20050818063535-e7d319791c19a8b2
    ------------------------------------------------------------
    revno: 3602.2.2
    revision-id: mbp at sourcefrog.net-20080804075541-jka7smxkix7ozvb1
    parent: mbp at sourcefrog.net-20080804064759-1vdd56edlca9j2rq
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: stacking
    timestamp: Mon 2008-08-04 17:55:41 +1000
    message:
      Make tests for stacked upgrade scenario-based
    added:
      bzrlib/tests/test_upgrade_stacked.py test_upgrade_stacked-20080804072225-jd13yami19nskns5-1
    modified:
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
    ------------------------------------------------------------
    revno: 3602.2.1
    revision-id: mbp at sourcefrog.net-20080804064759-1vdd56edlca9j2rq
    parent: pqm at pqm.ubuntu.com-20080804032751-myaykx8azatkvlf8
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: stacking
    timestamp: Mon 2008-08-04 16:47:59 +1000
    message:
      Fix and test for problem upgrading stacked branches
    modified:
      bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
      bzrlib/upgrade.py              history2weaves.py-20050818063535-e7d319791c19a8b2
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2008-08-01 04:40:30 +0000
+++ b/bzrlib/tests/__init__.py	2008-08-04 07:55:41 +0000
@@ -2815,6 +2815,7 @@
                    'bzrlib.tests.test_ui',
                    'bzrlib.tests.test_uncommit',
                    'bzrlib.tests.test_upgrade',
+                   'bzrlib.tests.test_upgrade_stacked',
                    'bzrlib.tests.test_urlutils',
                    'bzrlib.tests.test_versionedfile',
                    'bzrlib.tests.test_version',

=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py	2008-08-01 04:40:30 +0000
+++ b/bzrlib/tests/test_repository.py	2008-08-04 07:55:41 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007 Canonical Ltd
+# Copyright (C) 2006, 2007, 2008 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

=== added file 'bzrlib/tests/test_upgrade_stacked.py'
--- a/bzrlib/tests/test_upgrade_stacked.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/test_upgrade_stacked.py	2008-08-04 07:55:41 +0000
@@ -0,0 +1,90 @@
+# Copyright (C) 2008 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+"""Tests for upgrades of various stacking situations."""
+
+from bzrlib import (
+    bzrdir,
+    errors,
+    tests,
+    )
+from bzrlib.upgrade import upgrade
+
+
+class TestStackUpgrade(tests.TestCaseWithTransport):
+    # TODO: This should possibly be repeated for all stacking repositories,
+    # pairwise by rich/non-rich format; should possibly also try other kinds
+    # of upgrades like knit->pack. -- mbp 20080804
+
+    def test_stack_upgrade(self):
+        """Correct checks when stacked-on repository is upgraded.
+        
+        We initially stack on a repo with the same rich root support, 
+        we then upgrade it and should fail, we then upgrade the overlaid 
+        repository.
+        """
+        base = self.make_branch_and_tree('base',
+            format=self.scenario_old_format)
+        self.build_tree(['base/foo'])
+        base.commit('base commit')
+        # make another one stacked
+        stacked = base.bzrdir.sprout('stacked', stacked=True)
+        # this must really be stacked (or get_stacked_on_url raises an error)
+        self.assertTrue(stacked.open_branch().get_stacked_on_url())
+        # now we'll upgrade the underlying branch, then upgrade the stacked
+        # branch, and this should still work.
+        new_format = bzrdir.format_registry.make_bzrdir(
+            self.scenario_new_format)
+        upgrade('base', new_format)
+        # in some cases you'll get an error if the underlying model has
+        # changed; if just the data format has changed this should still work
+        if self.scenario_model_change:
+            self.assertRaises(errors.IncompatibleRepositories,
+                stacked.open_branch)
+        else:
+            stacked.open_branch().check()
+        stacked = bzrdir.BzrDir.open('stacked')
+        # but we can upgrade the stacked repository
+        upgrade('stacked', new_format)
+        # and now it's ok
+        stacked = bzrdir.BzrDir.open('stacked')
+        stacked.open_branch().check()
+
+
+def load_tests(basic_tests, module, test_loader):
+    """Generate dynamic scenario tests.
+
+    Called by the bzrlib test framework.
+    """
+    scenario_pairs = [ # old format, new format, model_change
+#        ('knit', 'rich-root', True),
+        ('knit', '1.6', False),
+#        ('pack-0.92', '1.6', False),
+        ('1.6', '1.6-rich-root', True),
+        ]
+    scenarios = []
+    for (old_name, new_name, model_change) in scenario_pairs:
+        name = old_name + ', ' + new_name
+        scenarios.append((name,
+            dict(scenario_old_format=old_name,
+                scenario_new_format=new_name,
+                scenario_model_change=model_change)))
+    adapter = tests.TestScenarioApplier()
+    adapter.scenarios = scenarios
+    suite = tests.TestSuite()
+    tests.adapt_tests(basic_tests, adapter, suite)
+    return suite

=== modified file 'bzrlib/upgrade.py'
--- a/bzrlib/upgrade.py	2008-03-14 21:31:15 +0000
+++ b/bzrlib/upgrade.py	2008-08-04 06:47:59 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Canonical Ltd
+# Copyright (C) 2005, 2008 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
@@ -47,12 +47,15 @@
                 self.pb.note("This is a checkout. The branch (%s) needs to be "
                              "upgraded separately.",
                              branch.bzrdir.root_transport.base)
-        except errors.NotBranchError:
+            del branch
+        except (errors.NotBranchError, errors.IncompatibleRepositories):
+            # might not be a format we can open without upgrading; see e.g. 
+            # https://bugs.launchpad.net/bzr/+bug/253891
             pass
         if not self.bzrdir.needs_format_conversion(self.format):
             raise errors.UpToDateFormat(self.bzrdir._format)
         if not self.bzrdir.can_convert_format():
-            raise errors.BzrError("cannot upgrade from branch format %s" %
+            raise errors.BzrError("cannot upgrade from bzrdir format %s" %
                            self.bzrdir._format)
         if self.format is None:
             target_format = BzrDirFormat.get_default_format()




More information about the bazaar-commits mailing list