101
101
url = get_transport(self.get_url('format_5_branch')).base
102
102
# check --format takes effect
103
103
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
104
backup_dir = 'backup.bzr.~1~'
104
105
(out, err) = self.run_bzr(
105
106
['upgrade', '--format=metaweave', url])
106
107
self.assertEqualDiff("""starting upgrade of %s
107
108
making backup of %s.bzr
109
110
starting upgrade from format 5 to 6
110
111
adding prefixes to weaves
111
112
adding prefixes to revision-store
112
113
starting upgrade from format 6 to metadir
114
""" % (url, url, url), out)
115
""" % (url, url, url, backup_dir), out)
115
116
self.assertEqualDiff("", err)
116
117
self.assertTrue(isinstance(
117
118
bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
124
125
url = get_transport(self.get_url('metadir_weave_branch')).base
125
126
# check --format takes effect
126
127
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
128
backup_dir = 'backup.bzr.~1~'
127
129
(out, err) = self.run_bzr(
128
130
['upgrade', '--format=knit', url])
129
131
self.assertEqualDiff("""starting upgrade of %s
130
132
making backup of %s.bzr
132
134
starting repository conversion
133
135
repository converted
135
""" % (url, url, url), out)
137
""" % (url, url, url, backup_dir), out)
136
138
self.assertEqualDiff("", err)
137
139
converted_dir = bzrdir.BzrDir.open(self.get_url('metadir_weave_branch'))
138
140
self.assertTrue(isinstance(converted_dir._format,
145
147
self.run_bzr('upgrade --format=knit repo')
150
def test_upgrade_with_existing_backup_dir(self):
151
self.make_format_5_branch()
152
transport = get_transport(self.get_url('format_5_branch'))
154
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
155
backup_dir1 = 'backup.bzr.~1~'
156
backup_dir2 = 'backup.bzr.~2~'
157
# explicitly create backup_dir1. bzr should create the .~2~ directory
159
transport.mkdir(backup_dir1)
160
(out, err) = self.run_bzr(
161
['upgrade', '--format=metaweave', url])
162
self.assertEqualDiff("""starting upgrade of %s
163
making backup of %s.bzr
165
starting upgrade from format 5 to 6
166
adding prefixes to weaves
167
adding prefixes to revision-store
168
starting upgrade from format 6 to metadir
170
""" % (url, url, url, backup_dir2), out)
171
self.assertEqualDiff("", err)
172
self.assertTrue(isinstance(
173
bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
174
bzrdir.BzrDirMetaFormat1))
175
self.assertTrue(transport.has(backup_dir2))
148
177
class SFTPTests(TestCaseWithSFTPServer):
149
178
"""Tests for upgrade over sftp."""
153
182
t = get_transport(self.get_url())
155
184
out, err = self.run_bzr(['upgrade', '--format=knit', url])
185
backup_dir = 'backup.bzr.~1~'
156
186
self.assertEqualDiff("""starting upgrade of %s
157
187
making backup of %s.bzr
159
189
starting upgrade from format 6 to metadir
160
190
starting repository conversion
161
191
repository converted
163
""" % (url, url, url), out)
193
""" % (url, url, url,backup_dir), out)
164
194
self.assertEqual('', err)