178
178
self.assertPathExists('checkout/file-1')
179
179
self.assertPathDoesNotExist('checkout/file-2')
181
def test_switch_into_colocated(self):
182
# Create a new colocated branch from an existing non-colocated branch.
183
tree = self.make_branch_and_tree('.', format='development-colo')
184
self.build_tree(['file-1', 'file-2'])
186
revid1 = tree.commit('rev1')
188
revid2 = tree.commit('rev2')
189
self.run_bzr(['switch', '-b', 'anotherbranch'])
191
['', 'anotherbranch'],
192
tree.branch.bzrdir.get_branches().keys())
194
def test_switch_into_unrelated_colocated(self):
195
# Create a new colocated branch from an existing non-colocated branch.
196
tree = self.make_branch_and_tree('.', format='development-colo')
197
self.build_tree(['file-1', 'file-2'])
199
revid1 = tree.commit('rev1')
201
revid2 = tree.commit('rev2')
202
tree.bzrdir.create_branch(name='foo')
203
self.run_bzr_error(['Cannot switch a branch, only a checkout.'],
205
self.run_bzr(['switch', '--force', 'foo'])
181
207
def test_switch_existing_colocated(self):
182
208
# Create a branch branch-1 that initially is a checkout of 'foo'
183
209
# Use switch to change it to 'anotherbranch'
184
210
repo = self.make_repository('branch-1', format='development-colo')
185
211
target_branch = repo.bzrdir.create_branch(name='foo')
186
branch.BranchReferenceFormat().initialize(
187
repo.bzrdir, target_branch=target_branch)
212
repo.bzrdir.set_branch_reference(target_branch)
188
213
tree = repo.bzrdir.create_workingtree()
189
214
self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
190
215
tree.add('file-1')
203
228
# Use switch to create 'anotherbranch' which derives from that
204
229
repo = self.make_repository('branch-1', format='development-colo')
205
230
target_branch = repo.bzrdir.create_branch(name='foo')
206
branch.BranchReferenceFormat().initialize(
207
repo.bzrdir, target_branch=target_branch)
231
repo.bzrdir.set_branch_reference(target_branch)
208
232
tree = repo.bzrdir.create_workingtree()
209
233
self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
210
234
tree.add('file-1')
223
247
self.requireFeature(UnicodeFilenameFeature)
224
248
repo = self.make_repository('branch-1', format='development-colo')
225
249
target_branch = repo.bzrdir.create_branch(name='foo')
226
branch.BranchReferenceFormat().initialize(
227
repo.bzrdir, target_branch=target_branch)
250
repo.bzrdir.set_branch_reference(target_branch)
228
251
tree = repo.bzrdir.create_workingtree()
229
252
self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
230
253
tree.add('file-1')