88
89
def test_upgrade_up_to_date(self):
89
90
self.make_current_format_branch_and_checkout()
90
91
# 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'
92
burl = self.get_transport('current_format_branch').local_abspath(".")
93
(out, err) = self.run_bzr('upgrade current_format_branch', retcode=0)
95
'Upgrading branch %s/ ...\n'
96
'The branch format %s is already at the most recent format.\n'
97
% (burl, 'Meta directory format 1'),
98
100
def test_upgrade_up_to_date_checkout_warns_branch_left_alone(self):
99
101
self.make_current_format_branch_and_checkout()
100
102
# when upgrading a checkout, the branch location and a suggestion
101
103
# 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)
105
burl = self.get_transport('current_format_branch').local_abspath(".")
106
curl = self.get_transport('current_format_checkout').local_abspath(".")
107
(out, err) = self.run_bzr('upgrade current_format_checkout', retcode=0)
106
108
self.assertEqual(
107
'Upgrading branch %s ...\nThis is a checkout.'
108
' The branch (%s) needs to be upgraded separately.\n'
109
'Upgrading branch %s/ ...\nThis is a checkout.'
110
' The branch (%s/) needs to be upgraded separately.\n'
111
'The branch format %s is already at the most recent format.\n'
112
% (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
115
def test_upgrade_checkout(self):
118
116
# upgrading a checkout should work
139
137
# setup an old format branch we can upgrade from.
140
138
path = 'old_format_branch'
141
139
self.make_branch_and_tree(path, format=old_format)
142
url = self.get_transport(path).base
140
transport = self.get_transport(path)
142
display_url = transport.local_abspath('.')
143
143
# check --format takes effect
144
144
controldir.ControlDirFormat._set_default_format(old_format)
145
145
backup_dir = 'backup.bzr.~1~'
146
146
(out, err) = self.run_bzr(
147
147
['upgrade', '--format=2a', url])
148
self.assertEqualDiff("""Upgrading branch %s ...
149
starting upgrade of %s
150
making backup of %s.bzr
148
self.assertEqualDiff("""Upgrading branch %s/ ...
149
starting upgrade of %s/
150
making backup of %s/.bzr
152
152
starting upgrade from old test format to 2a
154
""" % (url, url, url, url, backup_dir), out)
154
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
155
155
self.assertEqualDiff("", err)
156
156
self.assertTrue(isinstance(
157
157
bzrdir.BzrDir.open(self.get_url(path))._format,
161
161
# users can force an upgrade to knit format from a metadir pack 0.92
162
162
# branch to a 2a branch.
163
163
self.make_branch_and_tree('branch', format='knit')
164
url = self.get_transport('branch').base
164
transport = self.get_transport('branch')
166
display_url = transport.local_abspath('.')
165
167
# check --format takes effect
166
168
backup_dir = 'backup.bzr.~1~'
167
169
(out, err) = self.run_bzr(
168
170
['upgrade', '--format=pack-0.92', url])
169
self.assertEqualDiff("""Upgrading branch %s ...
170
starting upgrade of %s
171
making backup of %s.bzr
171
self.assertEqualDiff("""Upgrading branch %s/ ...
172
starting upgrade of %s/
173
making backup of %s/.bzr
173
175
starting repository conversion
174
176
repository converted
176
""" % (url, url, url, url, backup_dir),
178
""" % (display_url, display_url, display_url, display_url, backup_dir),
178
180
self.assertEqualDiff("", err)
179
181
converted_dir = bzrdir.BzrDir.open(self.get_url('branch'))
224
226
self.make_branch_and_tree("old_format_branch", format="knit")
225
227
t = self.get_transport("old_format_branch")
229
display_url = t.local_abspath('.')
227
230
backup_dir1 = 'backup.bzr.~1~'
228
231
backup_dir2 = 'backup.bzr.~2~'
229
232
# explicitly create backup_dir1. bzr should create the .~2~ directory
231
234
t.mkdir(backup_dir1)
232
235
(out, err) = self.run_bzr(
233
236
['upgrade', '--format=2a', url])
234
self.assertEqualDiff("""Upgrading branch %s ...
235
starting upgrade of %s
236
making backup of %s.bzr
237
self.assertEqualDiff("""Upgrading branch %s/ ...
238
starting upgrade of %s/
239
making backup of %s/.bzr
238
241
starting repository conversion
239
242
repository converted
241
""" % (url, url, url, url, backup_dir2), out)
244
""" % (display_url, display_url, display_url, display_url, backup_dir2), out)
242
245
self.assertEqualDiff("", err)
243
246
self.assertTrue(isinstance(
244
247
bzrdir.BzrDir.open(self.get_url("old_format_branch"))._format,
253
256
self.run_bzr('init --format=pack-0.92')
254
257
t = self.get_transport()
259
display_url = urlutils.unescape_for_display(url,
256
261
out, err = self.run_bzr(['upgrade', '--format=2a', url])
257
262
backup_dir = 'backup.bzr.~1~'
258
263
self.assertEqualDiff("""Upgrading branch %s ...
262
267
starting repository conversion
263
268
repository converted
265
""" % (url, url, url, url,backup_dir), out)
270
""" % (display_url, display_url, display_url, display_url, backup_dir), out)
266
271
self.assertEqual('', err)