~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-09 20:23:07 UTC
  • mfrom: (4265.1.4 bbc-merge)
  • Revision ID: pqm@pqm.ubuntu.com-20090409202307-n0depb16qepoe21o
(jam) Change _fetch_uses_deltas = False for CHK repos until we can
        write a better fix.

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
 
61
59
        bzrdir.BzrDirFormat._set_default_format(self.old_format)
62
60
 
63
61
    def test_readonly_url_error(self):
64
 
        (out, err) = self.run_bzr_captured(
65
 
            ['upgrade', self.get_readonly_url('format_5_branch')], 3)
 
62
        (out, err) = self.run_bzr(
 
63
            ['upgrade', self.get_readonly_url('format_5_branch')], retcode=3)
66
64
        self.assertEqual(out, "")
67
65
        self.assertEqual(err, "bzr: ERROR: Upgrade URL cannot work with readonly URLs.\n")
68
66
 
69
67
    def test_upgrade_up_to_date(self):
70
68
        # when up to date we should get a message to that effect
71
 
        (out, err) = self.run_bzr_captured(
72
 
            ['upgrade', 'current_format_branch'], 3)
 
69
        (out, err) = self.run_bzr('upgrade current_format_branch', retcode=3)
73
70
        self.assertEqual("", out)
74
 
        self.assertEqualDiff("bzr: ERROR: The branch format Bazaar-NG meta "
75
 
                             "directory, format 1 is already at the most "
 
71
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
 
72
                             "directory format 1 is already at the most "
76
73
                             "recent format.\n", err)
77
74
 
78
75
    def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
79
76
        # when upgrading a checkout, the branch location and a suggestion
80
 
        # to upgrade it should be emitted even if the checkout is up to 
 
77
        # to upgrade it should be emitted even if the checkout is up to
81
78
        # date
82
 
        (out, err) = self.run_bzr_captured(
83
 
            ['upgrade', 'current_format_checkout'], 3)
 
79
        (out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
84
80
        self.assertEqual("This is a checkout. The branch (%s) needs to be "
85
 
                         "upgraded separately.\n" 
 
81
                         "upgraded separately.\n"
86
82
                         % get_transport(self.get_url('current_format_branch')).base,
87
83
                         out)
88
 
        self.assertEqualDiff("bzr: ERROR: The branch format Bazaar-NG meta "
89
 
                             "directory, format 1 is already at the most "
 
84
        self.assertEqualDiff("bzr: ERROR: The branch format Meta "
 
85
                             "directory format 1 is already at the most "
90
86
                             "recent format.\n", err)
91
87
 
92
88
    def test_upgrade_checkout(self):
94
90
        pass
95
91
 
96
92
    def test_upgrade_repository_scans_branches(self):
97
 
        # we should get individual upgrade notes for each branch even the 
 
93
        # we should get individual upgrade notes for each branch even the
98
94
        # anonymous branch
99
95
        pass
100
96
 
107
103
        url = get_transport(self.get_url('format_5_branch')).base
108
104
        # check --format takes effect
109
105
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
110
 
        (out, err) = self.run_bzr_captured(
 
106
        (out, err) = self.run_bzr(
111
107
            ['upgrade', '--format=metaweave', url])
112
108
        self.assertEqualDiff("""starting upgrade of %s
113
 
making backup of tree history
114
 
%s.bzr has been backed up to %s.bzr.backup
115
 
if conversion fails, you can move this directory back to .bzr
116
 
if it succeeds, you can remove this directory if you wish
 
109
making backup of %s.bzr
 
110
  to %sbackup.bzr
117
111
starting upgrade from format 5 to 6
118
112
adding prefixes to weaves
119
113
adding prefixes to revision-store
126
120
            bzrdir.BzrDirMetaFormat1))
127
121
 
128
122
    def test_upgrade_explicit_knit(self):
129
 
        # users can force an upgrade to knit format from a metadir weave 
 
123
        # users can force an upgrade to knit format from a metadir weave
130
124
        # branch
131
125
        url = get_transport(self.get_url('metadir_weave_branch')).base
132
126
        # check --format takes effect
133
127
        bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
134
 
        (out, err) = self.run_bzr_captured(
 
128
        (out, err) = self.run_bzr(
135
129
            ['upgrade', '--format=knit', url])
136
130
        self.assertEqualDiff("""starting upgrade of %s
137
 
making backup of tree history
138
 
%s.bzr has been backed up to %s.bzr.backup
139
 
if conversion fails, you can move this directory back to .bzr
140
 
if it succeeds, you can remove this directory if you wish
 
131
making backup of %s.bzr
 
132
  to %sbackup.bzr
141
133
starting repository conversion
142
134
repository converted
143
135
finished
150
142
                                   RepositoryFormatKnit1))
151
143
 
152
144
    def test_upgrade_repo(self):
153
 
        self.run_bzr('init-repository', '--format=metaweave', 'repo')
154
 
        self.run_bzr('upgrade', '--format=knit', 'repo')
 
145
        self.run_bzr('init-repository --format=metaweave repo')
 
146
        self.run_bzr('upgrade --format=knit repo')
155
147
 
156
148
 
157
149
class SFTPTests(TestCaseWithSFTPServer):
168
160
        ui.ui_factory = self.old_ui_factory
169
161
 
170
162
    def test_upgrade_url(self):
171
 
        self.run_bzr('init', '--format=weave')
 
163
        self.run_bzr('init --format=weave')
172
164
        t = get_transport(self.get_url())
173
165
        url = t.base
174
 
        out, err = self.run_bzr('upgrade', '--format=knit', url)
 
166
        out, err = self.run_bzr(['upgrade', '--format=knit', url])
175
167
        self.assertEqualDiff("""starting upgrade of %s
176
 
making backup of tree history
177
 
%s.bzr has been backed up to %s.bzr.backup
178
 
if conversion fails, you can move this directory back to .bzr
179
 
if it succeeds, you can remove this directory if you wish
 
168
making backup of %s.bzr
 
169
  to %sbackup.bzr
180
170
starting upgrade from format 6 to metadir
181
171
starting repository conversion
182
172
repository converted
189
179
 
190
180
    def test_recommend_upgrade_wt4(self):
191
181
        # using a deprecated format gives a warning
192
 
        self.run_bzr('init', '--knit', 'a')
193
 
        out, err = self.run_bzr('status', 'a')
 
182
        self.run_bzr('init --knit a')
 
183
        out, err = self.run_bzr('status a')
194
184
        self.assertContainsRe(err, 'bzr upgrade .*[/\\\\]a')
195
185
 
196
186
    def test_no_upgrade_recommendation_from_bzrdir(self):
197
187
        # we should only get a recommendation to upgrade when we're accessing
198
188
        # the actual workingtree, not when we only open a bzrdir that contains
199
189
        # an old workngtree
200
 
        self.run_bzr('init', '--knit', 'a')
201
 
        out, err = self.run_bzr('checkout', 'a', 'b')
 
190
        self.run_bzr('init --knit a')
 
191
        out, err = self.run_bzr('revno a')
202
192
        if err.find('upgrade') > -1:
203
193
            self.fail("message shouldn't suggest upgrade:\n%s" % err)