/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: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2011 Canonical Ltd
 
1
# Copyright (C) 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
 
18
18
"""Tests for upgrades of various stacking situations."""
19
19
 
20
 
from .. import (
21
 
    controldir,
 
20
from bzrlib import (
 
21
    bzrdir,
22
22
    check,
23
23
    errors,
24
24
    tests,
25
25
    )
26
 
from ..upgrade import upgrade
27
 
from .scenarios import load_tests_apply_scenarios
28
 
 
29
 
 
30
 
def upgrade_scenarios():
31
 
    scenario_pairs = [  # old format, new format, model_change
32
 
        #        ('knit', 'rich-root', True),
33
 
        ('knit', '1.6', False),
34
 
        #        ('pack-0.92', '1.6', False),
35
 
        ('1.6', '1.6.1-rich-root', True),
36
 
        ]
37
 
    scenarios = []
38
 
    for (old_name, new_name, model_change) in scenario_pairs:
39
 
        name = old_name + ', ' + new_name
40
 
        scenarios.append((name,
41
 
                          dict(scenario_old_format=old_name,
42
 
                               scenario_new_format=new_name,
43
 
                               scenario_model_change=model_change)))
44
 
    return scenarios
45
 
 
46
 
 
47
 
load_tests = load_tests_apply_scenarios
 
26
from bzrlib.upgrade import upgrade
48
27
 
49
28
 
50
29
class TestStackUpgrade(tests.TestCaseWithTransport):
52
31
    # pairwise by rich/non-rich format; should possibly also try other kinds
53
32
    # of upgrades like knit->pack. -- mbp 20080804
54
33
 
55
 
    scenarios = upgrade_scenarios()
56
 
 
57
34
    def test_stack_upgrade(self):
58
35
        """Correct checks when stacked-on repository is upgraded.
59
36
 
62
39
        repository.
63
40
        """
64
41
        base = self.make_branch_and_tree('base',
65
 
                                         format=self.scenario_old_format)
 
42
            format=self.scenario_old_format)
66
43
        self.build_tree(['base/foo'])
67
44
        base.commit('base commit')
68
45
        # make another one stacked
69
 
        stacked = base.controldir.sprout('stacked', stacked=True)
 
46
        stacked = base.bzrdir.sprout('stacked', stacked=True)
70
47
        # this must really be stacked (or get_stacked_on_url raises an error)
71
48
        self.assertTrue(stacked.open_branch().get_stacked_on_url())
72
49
        # now we'll upgrade the underlying branch, then upgrade the stacked
73
50
        # branch, and this should still work.
74
 
        new_format = controldir.format_registry.make_controldir(
 
51
        new_format = bzrdir.format_registry.make_bzrdir(
75
52
            self.scenario_new_format)
76
53
        upgrade('base', new_format)
77
54
        # in some cases you'll get an error if the underlying model has
78
55
        # changed; if just the data format has changed this should still work
79
56
        if self.scenario_model_change:
80
57
            self.assertRaises(errors.IncompatibleRepositories,
81
 
                              stacked.open_branch)
 
58
                stacked.open_branch)
82
59
        else:
83
60
            check.check_dwim('stacked', False, True, True)
84
 
        stacked = controldir.ControlDir.open('stacked')
 
61
        stacked = bzrdir.BzrDir.open('stacked')
85
62
        # but we can upgrade the stacked repository
86
63
        upgrade('stacked', new_format)
87
64
        # and now it opens ok
88
 
        stacked = controldir.ControlDir.open('stacked')
 
65
        stacked = bzrdir.BzrDir.open('stacked')
89
66
        # And passes check.
90
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)