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