~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_upgrade.py

  • Committer: Robert Collins
  • Date: 2009-05-11 01:59:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4593.
  • Revision ID: robertc@robertcollins.net-20090511015906-6zi6a9b8tuuhipc8
Less lock thrashing in check.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        self.old_format = bzrdir.BzrDirFormat.get_default_format()
43
43
        self.old_ui_factory = ui.ui_factory
44
44
        self.addCleanup(self.restoreDefaults)
 
45
 
45
46
        ui.ui_factory = TestUIFactory()
46
 
 
47
 
    def restoreDefaults(self):
48
 
        ui.ui_factory = self.old_ui_factory
49
 
        bzrdir.BzrDirFormat._set_default_format(self.old_format)
50
 
 
51
 
    def make_current_format_branch_and_checkout(self):
 
47
        # setup a format 5 branch we can upgrade from.
 
48
        self.make_branch_and_tree('format_5_branch',
 
49
                                  format=bzrdir.BzrDirFormat5())
 
50
 
52
51
        current_tree = self.make_branch_and_tree('current_format_branch',
53
52
                                                 format='default')
 
53
        self.make_branch_and_tree('metadir_weave_branch', format='metaweave')
54
54
        current_tree.branch.create_checkout(
55
55
            self.get_url('current_format_checkout'), lightweight=True)
56
56
 
57
 
    def make_format_5_branch(self):
58
 
        # setup a format 5 branch we can upgrade from.
59
 
        self.make_branch_and_tree('format_5_branch',
60
 
                                  format=bzrdir.BzrDirFormat5())
61
 
 
62
 
    def make_metadir_weave_branch(self):
63
 
        self.make_branch_and_tree('metadir_weave_branch', format='metaweave')
 
57
    def restoreDefaults(self):
 
58
        ui.ui_factory = self.old_ui_factory
 
59
        bzrdir.BzrDirFormat._set_default_format(self.old_format)
64
60
 
65
61
    def test_readonly_url_error(self):
66
 
        self.make_format_5_branch()
67
62
        (out, err) = self.run_bzr(
68
63
            ['upgrade', self.get_readonly_url('format_5_branch')], retcode=3)
69
64
        self.assertEqual(out, "")
70
65
        self.assertEqual(err, "bzr: ERROR: Upgrade URL cannot work with readonly URLs.\n")
71
66
 
72
67
    def test_upgrade_up_to_date(self):
73
 
        self.make_current_format_branch_and_checkout()
74
68
        # when up to date we should get a message to that effect
75
69
        (out, err) = self.run_bzr('upgrade current_format_branch', retcode=3)
76
70
        self.assertEqual("", out)
79
73
                             "recent format.\n", err)
80
74
 
81
75
    def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
82
 
        self.make_current_format_branch_and_checkout()
83
76
        # when upgrading a checkout, the branch location and a suggestion
84
77
        # to upgrade it should be emitted even if the checkout is up to
85
78
        # date
107
100
 
108
101
    def test_upgrade_explicit_metaformat(self):
109
102
        # users can force an upgrade to metadir format.
110
 
        self.make_format_5_branch()
111
103
        url = get_transport(self.get_url('format_5_branch')).base
112
104
        # check --format takes effect
113
105
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
130
122
    def test_upgrade_explicit_knit(self):
131
123
        # users can force an upgrade to knit format from a metadir weave
132
124
        # branch
133
 
        self.make_metadir_weave_branch()
134
125
        url = get_transport(self.get_url('metadir_weave_branch')).base
135
126
        # check --format takes effect
136
127
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
184
175
        self.assertEqual('', err)
185
176
 
186
177
 
187
 
class UpgradeRecommendedTests(TestCaseWithTransport):
 
178
class UpgradeRecommendedTests(TestCaseInTempDir):
188
179
 
189
180
    def test_recommend_upgrade_wt4(self):
190
181
        # using a deprecated format gives a warning
200
191
        out, err = self.run_bzr('revno a')
201
192
        if err.find('upgrade') > -1:
202
193
            self.fail("message shouldn't suggest upgrade:\n%s" % err)
203
 
 
204
 
    def test_upgrade_shared_repo(self):
205
 
        repo = self.make_repository('repo', format='2a', shared=True)
206
 
        branch = self.make_branch_and_tree('repo/branch', format="pack-0.92")
207
 
        self.get_transport('repo/branch/.bzr/repository').delete_tree('.')
208
 
        out, err = self.run_bzr(['upgrade'], working_dir='repo/branch')