150
150
self.run_bzr('switch --force branch1', working_dir='tree')
151
151
branch_location = WorkingTree.open('tree').branch.base
152
152
self.assertEndsWith(branch_location, 'branch1/')
154
def test_create_branch_no_branch(self):
155
self.prepare_lightweight_switch()
156
self.run_bzr_error(['cannot create branch without source branch'],
157
'switch --create-branch ../branch2', working_dir='tree')
159
def test_create_branch(self):
160
branch = self.make_branch('branch')
161
tree = branch.create_checkout('tree', lightweight=True)
162
tree.commit('one', rev_id='rev-1')
163
self.run_bzr('switch --create-branch ../branch2', working_dir='tree')
164
tree = WorkingTree.open('tree')
165
self.assertEndsWith(tree.branch.base, '/branch2/')
167
def test_create_branch_local(self):
168
branch = self.make_branch('branch')
169
tree = branch.create_checkout('tree', lightweight=True)
170
tree.commit('one', rev_id='rev-1')
171
self.run_bzr('switch --create-branch branch2', working_dir='tree')
172
tree = WorkingTree.open('tree')
173
# The new branch should have been created at the same level as
174
# 'branch', because we did not have a '/' segment
175
self.assertEqual(branch.base[:-1] + '2/', tree.branch.base)
177
def test_create_branch_short_name(self):
178
branch = self.make_branch('branch')
179
tree = branch.create_checkout('tree', lightweight=True)
180
tree.commit('one', rev_id='rev-1')
181
self.run_bzr('switch -b branch2', working_dir='tree')
182
tree = WorkingTree.open('tree')
183
# The new branch should have been created at the same level as
184
# 'branch', because we did not have a '/' segment
185
self.assertEqual(branch.base[:-1] + '2/', tree.branch.base)