88
90
def test_upgrade_up_to_date(self):
89
91
self.make_current_format_branch_and_checkout()
90
92
# when up to date we should get a message to that effect
91
(out, err) = self.run_bzr('upgrade current_format_branch', retcode=3)
92
err_msg = ('The branch format %s is already at the most recent format.'
93
% ('Meta directory format 1'))
94
self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
93
burl = self.get_transport('current_format_branch').local_abspath(".")
94
(out, err) = self.run_bzr('upgrade current_format_branch', retcode=0)
96
'Upgrading branch %s/ ...\n'
97
'The branch format %s is already at the most recent format.\n'
98
% (burl, 'Meta directory format 1'),
98
101
def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
99
102
self.make_current_format_branch_and_checkout()
100
103
# when upgrading a checkout, the branch location and a suggestion
101
104
# to upgrade it should be emitted even if the checkout is up to
103
burl = self.get_transport('current_format_branch').base
104
curl = self.get_transport('current_format_checkout').base
105
(out, err) = self.run_bzr('upgrade current_format_checkout', retcode=3)
106
burl = self.get_transport('current_format_branch').local_abspath(".")
107
curl = self.get_transport('current_format_checkout').local_abspath(".")
108
(out, err) = self.run_bzr('upgrade current_format_checkout', retcode=0)
106
109
self.assertEqual(
107
'Upgrading branch %s ...\nThis is a checkout.'
108
' The branch (%s) needs to be upgraded separately.\n'
110
'Upgrading branch %s/ ...\nThis is a checkout.'
111
' The branch (%s/) needs to be upgraded separately.\n'
112
'The branch format %s is already at the most recent format.\n'
113
% (curl, burl, 'Meta directory format 1'),
111
msg = 'The branch format %s is already at the most recent format.' % (
112
'Meta directory format 1')
113
self.assertEqualDiff('conversion error: %s\nbzr: ERROR: %s\n'
117
116
def test_upgrade_checkout(self):
118
117
# upgrading a checkout should work
139
138
# setup an old format branch we can upgrade from.
140
139
path = 'old_format_branch'
141
140
self.make_branch_and_tree(path, format=old_format)
142
url = self.get_transport(path).base
141
transport = self.get_transport(path)
143
display_url = transport.local_abspath('.')
143
144
# check --format takes effect
144
145
controldir.ControlDirFormat._set_default_format(old_format)
145
146
backup_dir = 'backup.bzr.~1~'
146
147
(out, err) = self.run_bzr(
147
148
['upgrade', '--format=2a', url])
148
self.assertEqualDiff("""Upgrading branch %s ...
149
starting upgrade of %s
150
making backup of %s.bzr
149
self.assertEqualDiff("""Upgrading branch %s/ ...
150
starting upgrade of %s/
151
making backup of %s/.bzr
152
153
starting upgrade from old test format to 2a
154
""" % (url, url, url, url, backup_dir), out)
155
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
155
156
self.assertEqualDiff("", err)
156
157
self.assertTrue(isinstance(
157
bzrdir.BzrDir.open(self.get_url(path))._format,
158
controldir.ControlDir.open(self.get_url(path))._format,
158
159
bzrdir.BzrDirMetaFormat1))
160
161
def test_upgrade_explicit_knit(self):
161
162
# users can force an upgrade to knit format from a metadir pack 0.92
162
163
# branch to a 2a branch.
163
164
self.make_branch_and_tree('branch', format='knit')
164
url = self.get_transport('branch').base
165
transport = self.get_transport('branch')
167
display_url = transport.local_abspath('.')
165
168
# check --format takes effect
166
169
backup_dir = 'backup.bzr.~1~'
167
170
(out, err) = self.run_bzr(
168
171
['upgrade', '--format=pack-0.92', url])
169
self.assertEqualDiff("""Upgrading branch %s ...
170
starting upgrade of %s
171
making backup of %s.bzr
172
self.assertEqualDiff("""Upgrading branch %s/ ...
173
starting upgrade of %s/
174
making backup of %s/.bzr
173
176
starting repository conversion
174
177
repository converted
176
""" % (url, url, url, url, backup_dir),
179
""" % (display_url, display_url, display_url, display_url, backup_dir),
178
181
self.assertEqualDiff("", err)
179
converted_dir = bzrdir.BzrDir.open(self.get_url('branch'))
182
converted_dir = controldir.ControlDir.open(self.get_url('branch'))
180
183
self.assertTrue(isinstance(converted_dir._format,
181
184
bzrdir.BzrDirMetaFormat1))
182
185
self.assertTrue(isinstance(converted_dir.open_repository()._format,
193
196
self.run_bzr('upgrade --format=2a branch-foo %s' % (option_str,))
195
198
def assertBranchFormat(self, dir, format):
196
branch = bzrdir.BzrDir.open_tree_or_branch(self.get_url(dir))[1]
199
branch = controldir.ControlDir.open_tree_or_branch(self.get_url(dir))[1]
197
200
branch_format = branch._format
198
meta_format = bzrdir.format_registry.make_bzrdir(format)
201
meta_format = controldir.format_registry.make_bzrdir(format)
199
202
expected_format = meta_format.get_branch_format()
200
203
self.assertEqual(expected_format, branch_format)
231
235
t.mkdir(backup_dir1)
232
236
(out, err) = self.run_bzr(
233
237
['upgrade', '--format=2a', url])
234
self.assertEqualDiff("""Upgrading branch %s ...
235
starting upgrade of %s
236
making backup of %s.bzr
238
self.assertEqualDiff("""Upgrading branch %s/ ...
239
starting upgrade of %s/
240
making backup of %s/.bzr
238
242
starting repository conversion
239
243
repository converted
241
""" % (url, url, url, url, backup_dir2), out)
245
""" % (display_url, display_url, display_url, display_url, backup_dir2), out)
242
246
self.assertEqualDiff("", err)
243
247
self.assertTrue(isinstance(
244
bzrdir.BzrDir.open(self.get_url("old_format_branch"))._format,
248
controldir.ControlDir.open(self.get_url("old_format_branch"))._format,
245
249
bzrdir.BzrDirMetaFormat1))
246
250
self.assertTrue(t.has(backup_dir2))
262
268
starting repository conversion
263
269
repository converted
265
""" % (url, url, url, url,backup_dir), out)
271
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
266
272
self.assertEqual('', err)