/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: 2008-07-09 21:42:24 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080709214224-r75k87r6a01pfc3h
Restore a real weave merge to 'bzr merge --weave'.

To do so efficiently, we only add the simple LCAs to the final weave
object, unless we run into complexities with the merge graph.
This gives the same effective result as adding all the texts,
with the advantage of not having to extract all of them.

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
 
    check,
23
 
    errors,
24
 
    tests,
25
 
    )
26
 
from bzrlib.upgrade import upgrade
27
 
 
28
 
 
29
 
class TestStackUpgrade(tests.TestCaseWithTransport):
30
 
    # TODO: This should possibly be repeated for all stacking repositories,
31
 
    # pairwise by rich/non-rich format; should possibly also try other kinds
32
 
    # of upgrades like knit->pack. -- mbp 20080804
33
 
 
34
 
    def test_stack_upgrade(self):
35
 
        """Correct checks when stacked-on repository is upgraded.
36
 
 
37
 
        We initially stack on a repo with the same rich root support,
38
 
        we then upgrade it and should fail, we then upgrade the overlaid
39
 
        repository.
40
 
        """
41
 
        base = self.make_branch_and_tree('base',
42
 
            format=self.scenario_old_format)
43
 
        self.build_tree(['base/foo'])
44
 
        base.commit('base commit')
45
 
        # make another one stacked
46
 
        stacked = base.bzrdir.sprout('stacked', stacked=True)
47
 
        # this must really be stacked (or get_stacked_on_url raises an error)
48
 
        self.assertTrue(stacked.open_branch().get_stacked_on_url())
49
 
        # now we'll upgrade the underlying branch, then upgrade the stacked
50
 
        # branch, and this should still work.
51
 
        new_format = bzrdir.format_registry.make_bzrdir(
52
 
            self.scenario_new_format)
53
 
        upgrade('base', new_format)
54
 
        # in some cases you'll get an error if the underlying model has
55
 
        # changed; if just the data format has changed this should still work
56
 
        if self.scenario_model_change:
57
 
            self.assertRaises(errors.IncompatibleRepositories,
58
 
                stacked.open_branch)
59
 
        else:
60
 
            check.check_dwim('stacked', False, True, True)
61
 
        stacked = bzrdir.BzrDir.open('stacked')
62
 
        # but we can upgrade the stacked repository
63
 
        upgrade('stacked', new_format)
64
 
        # and now it opens ok
65
 
        stacked = bzrdir.BzrDir.open('stacked')
66
 
        # And passes check.
67
 
        check.check_dwim('stacked', False, True, True)
68
 
 
69
 
 
70
 
def load_tests(basic_tests, module, loader):
71
 
    """Generate dynamic scenario tests.
72
 
 
73
 
    Called by the bzrlib test framework.
74
 
    """
75
 
    scenario_pairs = [ # old format, new format, model_change
76
 
#        ('knit', 'rich-root', True),
77
 
        ('knit', '1.6', False),
78
 
#        ('pack-0.92', '1.6', False),
79
 
        ('1.6', '1.6.1-rich-root', True),
80
 
        ]
81
 
    scenarios = []
82
 
    for (old_name, new_name, model_change) in scenario_pairs:
83
 
        name = old_name + ', ' + new_name
84
 
        scenarios.append((name,
85
 
            dict(scenario_old_format=old_name,
86
 
                scenario_new_format=new_name,
87
 
                scenario_model_change=model_change)))
88
 
    suite = loader.suiteClass()
89
 
    return tests.multiply_tests(basic_tests, scenarios, suite)