/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_upgrade_stacked.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-18 18:18:36 UTC
  • mto: This revision was merged to the branch mainline in revision 4461.
  • Revision ID: john@arbash-meinel.com-20090618181836-biodfkat9a8eyzjz
The new add_inventory_by_delta is returning a CHKInventory when mapping from NULL
Which is completely valid, but 'broke' one of the tests.
So to fix it, changed the test to use CHKInventories on both sides, and add an __eq__
member. The nice thing is that CHKInventory.__eq__ is fairly cheap, since it only
has to check the root keys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
 
 
18
"""Tests for upgrades of various stacking situations."""
 
19
 
 
20
from bzrlib import (
 
21
    bzrdir,
 
22
    errors,
 
23
    tests,
 
24
    )
 
25
from bzrlib.upgrade import upgrade
 
26
 
 
27
 
 
28
class TestStackUpgrade(tests.TestCaseWithTransport):
 
29
    # TODO: This should possibly be repeated for all stacking repositories,
 
30
    # pairwise by rich/non-rich format; should possibly also try other kinds
 
31
    # of upgrades like knit->pack. -- mbp 20080804
 
32
 
 
33
    def test_stack_upgrade(self):
 
34
        """Correct checks when stacked-on repository is upgraded.
 
35
 
 
36
        We initially stack on a repo with the same rich root support,
 
37
        we then upgrade it and should fail, we then upgrade the overlaid
 
38
        repository.
 
39
        """
 
40
        base = self.make_branch_and_tree('base',
 
41
            format=self.scenario_old_format)
 
42
        self.build_tree(['base/foo'])
 
43
        base.commit('base commit')
 
44
        # make another one stacked
 
45
        stacked = base.bzrdir.sprout('stacked', stacked=True)
 
46
        # this must really be stacked (or get_stacked_on_url raises an error)
 
47
        self.assertTrue(stacked.open_branch().get_stacked_on_url())
 
48
        # now we'll upgrade the underlying branch, then upgrade the stacked
 
49
        # branch, and this should still work.
 
50
        new_format = bzrdir.format_registry.make_bzrdir(
 
51
            self.scenario_new_format)
 
52
        upgrade('base', new_format)
 
53
        # in some cases you'll get an error if the underlying model has
 
54
        # changed; if just the data format has changed this should still work
 
55
        if self.scenario_model_change:
 
56
            self.assertRaises(errors.IncompatibleRepositories,
 
57
                stacked.open_branch)
 
58
        else:
 
59
            stacked.open_branch().check()
 
60
        stacked = bzrdir.BzrDir.open('stacked')
 
61
        # but we can upgrade the stacked repository
 
62
        upgrade('stacked', new_format)
 
63
        # and now it's ok
 
64
        stacked = bzrdir.BzrDir.open('stacked')
 
65
        stacked.open_branch().check()
 
66
 
 
67
 
 
68
def load_tests(basic_tests, module, loader):
 
69
    """Generate dynamic scenario tests.
 
70
 
 
71
    Called by the bzrlib test framework.
 
72
    """
 
73
    scenario_pairs = [ # old format, new format, model_change
 
74
#        ('knit', 'rich-root', True),
 
75
        ('knit', '1.6', False),
 
76
#        ('pack-0.92', '1.6', False),
 
77
        ('1.6', '1.6.1-rich-root', True),
 
78
        ]
 
79
    scenarios = []
 
80
    for (old_name, new_name, model_change) in scenario_pairs:
 
81
        name = old_name + ', ' + new_name
 
82
        scenarios.append((name,
 
83
            dict(scenario_old_format=old_name,
 
84
                scenario_new_format=new_name,
 
85
                scenario_model_change=model_change)))
 
86
    suite = loader.suiteClass()
 
87
    return tests.multiply_tests(basic_tests, scenarios, suite)