59
58
def get_converter(self, format=None):
60
59
return ConvertOldTestToMeta()
63
def get_format_string(cls):
61
def get_format_string(self):
64
62
return "Ancient Test Format"
66
64
def _open(self, transport):
90
88
def test_upgrade_up_to_date(self):
91
89
self.make_current_format_branch_and_checkout()
92
90
# when up to date we should get a message to that effect
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'),
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'
101
98
def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
102
99
self.make_current_format_branch_and_checkout()
103
100
# when upgrading a checkout, the branch location and a suggestion
104
101
# to upgrade it should be emitted even if the checkout is up to
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)
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)
109
106
self.assertEqual(
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'),
107
'Upgrading branch %s ...\nThis is a checkout.'
108
' The branch (%s) needs to be upgraded separately.\n'
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'
116
117
def test_upgrade_checkout(self):
117
118
# upgrading a checkout should work
138
139
# setup an old format branch we can upgrade from.
139
140
path = 'old_format_branch'
140
141
self.make_branch_and_tree(path, format=old_format)
141
transport = self.get_transport(path)
143
display_url = transport.local_abspath('.')
142
url = self.get_transport(path).base
144
143
# check --format takes effect
145
144
controldir.ControlDirFormat._set_default_format(old_format)
146
145
backup_dir = 'backup.bzr.~1~'
147
146
(out, err) = self.run_bzr(
148
147
['upgrade', '--format=2a', url])
149
self.assertEqualDiff("""Upgrading branch %s/ ...
150
starting upgrade of %s/
151
making backup of %s/.bzr
148
self.assertEqualDiff("""Upgrading branch %s ...
149
starting upgrade of %s
150
making backup of %s.bzr
153
152
starting upgrade from old test format to 2a
155
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
154
""" % (url, url, url, url, backup_dir), out)
156
155
self.assertEqualDiff("", err)
157
156
self.assertTrue(isinstance(
158
157
bzrdir.BzrDir.open(self.get_url(path))._format,
162
161
# users can force an upgrade to knit format from a metadir pack 0.92
163
162
# branch to a 2a branch.
164
163
self.make_branch_and_tree('branch', format='knit')
165
transport = self.get_transport('branch')
167
display_url = transport.local_abspath('.')
164
url = self.get_transport('branch').base
168
165
# check --format takes effect
169
166
backup_dir = 'backup.bzr.~1~'
170
167
(out, err) = self.run_bzr(
171
168
['upgrade', '--format=pack-0.92', url])
172
self.assertEqualDiff("""Upgrading branch %s/ ...
173
starting upgrade of %s/
174
making backup of %s/.bzr
169
self.assertEqualDiff("""Upgrading branch %s ...
170
starting upgrade of %s
171
making backup of %s.bzr
176
173
starting repository conversion
177
174
repository converted
179
""" % (display_url, display_url, display_url, display_url, backup_dir),
176
""" % (url, url, url, url, backup_dir),
181
178
self.assertEqualDiff("", err)
182
179
converted_dir = bzrdir.BzrDir.open(self.get_url('branch'))
227
224
self.make_branch_and_tree("old_format_branch", format="knit")
228
225
t = self.get_transport("old_format_branch")
230
display_url = t.local_abspath('.')
231
227
backup_dir1 = 'backup.bzr.~1~'
232
228
backup_dir2 = 'backup.bzr.~2~'
233
229
# explicitly create backup_dir1. bzr should create the .~2~ directory
235
231
t.mkdir(backup_dir1)
236
232
(out, err) = self.run_bzr(
237
233
['upgrade', '--format=2a', url])
238
self.assertEqualDiff("""Upgrading branch %s/ ...
239
starting upgrade of %s/
240
making backup of %s/.bzr
234
self.assertEqualDiff("""Upgrading branch %s ...
235
starting upgrade of %s
236
making backup of %s.bzr
242
238
starting repository conversion
243
239
repository converted
245
""" % (display_url, display_url, display_url, display_url, backup_dir2), out)
241
""" % (url, url, url, url, backup_dir2), out)
246
242
self.assertEqualDiff("", err)
247
243
self.assertTrue(isinstance(
248
244
bzrdir.BzrDir.open(self.get_url("old_format_branch"))._format,
257
253
self.run_bzr('init --format=pack-0.92')
258
254
t = self.get_transport()
260
display_url = urlutils.unescape_for_display(url,
262
256
out, err = self.run_bzr(['upgrade', '--format=2a', url])
263
257
backup_dir = 'backup.bzr.~1~'
264
258
self.assertEqualDiff("""Upgrading branch %s ...
268
262
starting repository conversion
269
263
repository converted
271
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
265
""" % (url, url, url, url,backup_dir), out)
272
266
self.assertEqual('', err)