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