58
59
def get_converter(self, format=None):
59
60
return ConvertOldTestToMeta()
61
def get_format_string(self):
63
def get_format_string(cls):
62
64
return "Ancient Test Format"
64
66
def _open(self, transport):
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
158
bzrdir.BzrDir.open(self.get_url(path))._format,
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
182
converted_dir = bzrdir.BzrDir.open(self.get_url('branch'))
224
227
self.make_branch_and_tree("old_format_branch", format="knit")
225
228
t = self.get_transport("old_format_branch")
230
display_url = t.local_abspath('.')
227
231
backup_dir1 = 'backup.bzr.~1~'
228
232
backup_dir2 = 'backup.bzr.~2~'
229
233
# explicitly create backup_dir1. bzr should create the .~2~ directory
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
248
bzrdir.BzrDir.open(self.get_url("old_format_branch"))._format,
253
257
self.run_bzr('init --format=pack-0.92')
254
258
t = self.get_transport()
260
display_url = urlutils.unescape_for_display(url,
256
262
out, err = self.run_bzr(['upgrade', '--format=2a', url])
257
backup_dir = 'backup.bzr.%7E1%7E'
263
backup_dir = 'backup.bzr.~1~'
258
264
self.assertEqualDiff("""Upgrading branch %s ...
259
265
starting upgrade of %s
260
266
making backup of %s.bzr
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)