37
41
super(TestWithUpgradableBranches, self).setUp()
38
self.addCleanup(bzrdir.BzrDirFormat._set_default_format,
39
bzrdir.BzrDirFormat.get_default_format())
42
self.old_format = bzrdir.BzrDirFormat.get_default_format()
43
self.old_ui_factory = ui.ui_factory
44
self.addCleanup(self.restoreDefaults)
45
ui.ui_factory = TestUIFactory()
47
def restoreDefaults(self):
48
ui.ui_factory = self.old_ui_factory
49
bzrdir.BzrDirFormat._set_default_format(self.old_format)
41
51
def make_current_format_branch_and_checkout(self):
42
52
current_tree = self.make_branch_and_tree('current_format_branch',
101
111
url = get_transport(self.get_url('format_5_branch')).base
102
112
# check --format takes effect
103
113
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
104
backup_dir = 'backup.bzr.~1~'
105
114
(out, err) = self.run_bzr(
106
115
['upgrade', '--format=metaweave', url])
107
116
self.assertEqualDiff("""starting upgrade of %s
108
117
making backup of %s.bzr
110
119
starting upgrade from format 5 to 6
111
120
adding prefixes to weaves
112
121
adding prefixes to revision-store
113
122
starting upgrade from format 6 to metadir
115
""" % (url, url, url, backup_dir), out)
124
""" % (url, url, url), out)
116
125
self.assertEqualDiff("", err)
117
126
self.assertTrue(isinstance(
118
127
bzrdir.BzrDir.open(self.get_url('format_5_branch'))._format,
125
134
url = get_transport(self.get_url('metadir_weave_branch')).base
126
135
# check --format takes effect
127
136
bzrdir.BzrDirFormat._set_default_format(bzrdir.BzrDirFormat5())
128
backup_dir = 'backup.bzr.~1~'
129
137
(out, err) = self.run_bzr(
130
138
['upgrade', '--format=knit', url])
131
139
self.assertEqualDiff("""starting upgrade of %s
132
140
making backup of %s.bzr
134
142
starting repository conversion
135
143
repository converted
137
""" % (url, url, url, backup_dir), out)
145
""" % (url, url, url), out)
138
146
self.assertEqualDiff("", err)
139
147
converted_dir = bzrdir.BzrDir.open(self.get_url('metadir_weave_branch'))
140
148
self.assertTrue(isinstance(converted_dir._format,
147
155
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))
177
158
class SFTPTests(TestCaseWithSFTPServer):
178
159
"""Tests for upgrade over sftp."""
162
super(SFTPTests, self).setUp()
163
self.old_ui_factory = ui.ui_factory
164
self.addCleanup(self.restoreDefaults)
166
ui.ui_factory = TestUIFactory()
168
def restoreDefaults(self):
169
ui.ui_factory = self.old_ui_factory
180
171
def test_upgrade_url(self):
181
172
self.run_bzr('init --format=weave')
182
173
t = get_transport(self.get_url())
184
175
out, err = self.run_bzr(['upgrade', '--format=knit', url])
185
backup_dir = 'backup.bzr.~1~'
186
176
self.assertEqualDiff("""starting upgrade of %s
187
177
making backup of %s.bzr
189
179
starting upgrade from format 6 to metadir
190
180
starting repository conversion
191
181
repository converted
193
""" % (url, url, url,backup_dir), out)
183
""" % (url, url, url), out)
194
184
self.assertEqual('', err)