~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Ferlito
  • Date: 2009-09-02 04:31:45 UTC
  • mto: (4665.7.1 serve-init)
  • mto: This revision was merged to the branch mainline in revision 4913.
  • Revision ID: johnf@inodes.org-20090902043145-gxdsfw03ilcwbyn5
Add a debian init script for bzr --serve

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
2
 
# Authors: Robert Collins <robert.collins@canonical.com>
3
 
#          and others
 
1
# Copyright (C) 2006, 2007, 2009 Canonical Ltd
4
2
#
5
3
# This program is free software; you can redistribute it and/or modify
6
4
# it under the terms of the GNU General Public License as published by
14
12
#
15
13
# You should have received a copy of the GNU General Public License
16
14
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
16
 
19
17
"""Black box tests for the upgrade ui."""
20
18
 
44
42
        self.old_format = bzrdir.BzrDirFormat.get_default_format()
45
43
        self.old_ui_factory = ui.ui_factory
46
44
        self.addCleanup(self.restoreDefaults)
47
 
 
48
45
        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):
 
52
        current_tree = self.make_branch_and_tree('current_format_branch',
 
53
                                                 format='default')
 
54
        current_tree.branch.create_checkout(
 
55
            self.get_url('current_format_checkout'), lightweight=True)
 
56
 
 
57
    def make_format_5_branch(self):
49
58
        # setup a format 5 branch we can upgrade from.
50
59
        self.make_branch_and_tree('format_5_branch',
51
60
                                  format=bzrdir.BzrDirFormat5())
52
61
 
53
 
        current_tree = self.make_branch_and_tree('current_format_branch',
54
 
                                                 format='default')
 
62
    def make_metadir_weave_branch(self):
55
63
        self.make_branch_and_tree('metadir_weave_branch', format='metaweave')
56
 
        current_tree.branch.create_checkout(
57
 
            self.get_url('current_format_checkout'), lightweight=True)
58
 
 
59
 
    def restoreDefaults(self):
60
 
        ui.ui_factory = self.old_ui_factory
61
 
        bzrdir.BzrDirFormat._set_default_format(self.old_format)
62
64
 
63
65
    def test_readonly_url_error(self):
 
66
        self.make_format_5_branch()
64
67
        (out, err) = self.run_bzr(
65
68
            ['upgrade', self.get_readonly_url('format_5_branch')], retcode=3)
66
69
        self.assertEqual(out, "")
67
70
        self.assertEqual(err, "bzr: ERROR: Upgrade URL cannot work with readonly URLs.\n")
68
71
 
69
72
    def test_upgrade_up_to_date(self):
 
73
        self.make_current_format_branch_and_checkout()
70
74
        # when up to date we should get a message to that effect
71
75
        (out, err) = self.run_bzr('upgrade current_format_branch', retcode=3)
72
76
        self.assertEqual("", out)
73
 
        self.assertEqualDiff("bzr: ERROR: The branch format Bazaar-NG meta "
74
 
                             "directory, format 1 is already at the most "
 
77
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
 
78
                             "directory format 1 is already at the most "
75
79
                             "recent format.\n", err)
76
80
 
77
81
    def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
 
82
        self.make_current_format_branch_and_checkout()
78
83
        # when upgrading a checkout, the branch location and a suggestion
79
 
        # to upgrade it should be emitted even if the checkout is up to 
 
84
        # to upgrade it should be emitted even if the checkout is up to
80
85
        # date
81
86
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
82
87
        self.assertEqual("This is a checkout. The branch (%s) needs to be "
83
88
                         "upgraded separately.\n"
84
89
                         % get_transport(self.get_url('current_format_branch')).base,
85
90
                         out)
86
 
        self.assertEqualDiff("bzr: ERROR: The branch format Bazaar-NG meta "
87
 
                             "directory, format 1 is already at the most "
 
91
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
 
92
                             "directory format 1 is already at the most "
88
93
                             "recent format.\n", err)
89
94
 
90
95
    def test_upgrade_checkout(self):
92
97
        pass
93
98
 
94
99
    def test_upgrade_repository_scans_branches(self):
95
 
        # we should get individual upgrade notes for each branch even the 
 
100
        # we should get individual upgrade notes for each branch even the
96
101
        # anonymous branch
97
102
        pass
98
103
 
102
107
 
103
108
    def test_upgrade_explicit_metaformat(self):
104
109
        # users can force an upgrade to metadir format.
 
110
        self.make_format_5_branch()
105
111
        url = get_transport(self.get_url('format_5_branch')).base
106
112
        # check --format takes effect
107
113
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
108
114
        (out, err) = self.run_bzr(
109
115
            ['upgrade', '--format=metaweave', url])
110
116
        self.assertEqualDiff("""starting upgrade of %s
111
 
making backup of tree history
112
 
%s.bzr has been backed up to %sbackup.bzr
113
 
if conversion fails, you can move this directory back to .bzr
114
 
if it succeeds, you can remove this directory if you wish
 
117
making backup of %s.bzr
 
118
  to %sbackup.bzr
115
119
starting upgrade from format 5 to 6
116
120
adding prefixes to weaves
117
121
adding prefixes to revision-store
124
128
            bzrdir.BzrDirMetaFormat1))
125
129
 
126
130
    def test_upgrade_explicit_knit(self):
127
 
        # users can force an upgrade to knit format from a metadir weave 
 
131
        # users can force an upgrade to knit format from a metadir weave
128
132
        # branch
 
133
        self.make_metadir_weave_branch()
129
134
        url = get_transport(self.get_url('metadir_weave_branch')).base
130
135
        # check --format takes effect
131
136
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
132
137
        (out, err) = self.run_bzr(
133
138
            ['upgrade', '--format=knit', url])
134
139
        self.assertEqualDiff("""starting upgrade of %s
135
 
making backup of tree history
136
 
%s.bzr has been backed up to %sbackup.bzr
137
 
if conversion fails, you can move this directory back to .bzr
138
 
if it succeeds, you can remove this directory if you wish
 
140
making backup of %s.bzr
 
141
  to %sbackup.bzr
139
142
starting repository conversion
140
143
repository converted
141
144
finished
171
174
        url = t.base
172
175
        out, err = self.run_bzr(['upgrade', '--format=knit', url])
173
176
        self.assertEqualDiff("""starting upgrade of %s
174
 
making backup of tree history
175
 
%s.bzr has been backed up to %sbackup.bzr
176
 
if conversion fails, you can move this directory back to .bzr
177
 
if it succeeds, you can remove this directory if you wish
 
177
making backup of %s.bzr
 
178
  to %sbackup.bzr
178
179
starting upgrade from format 6 to metadir
179
180
starting repository conversion
180
181
repository converted
183
184
        self.assertEqual('', err)
184
185
 
185
186
 
186
 
class UpgradeRecommendedTests(TestCaseInTempDir):
 
187
class UpgradeRecommendedTests(TestCaseWithTransport):
187
188
 
188
189
    def test_recommend_upgrade_wt4(self):
189
190
        # using a deprecated format gives a warning
199
200
        out, err = self.run_bzr('revno a')
200
201
        if err.find('upgrade') > -1:
201
202
            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')