317
317
def test_create_branch(self):
318
318
branch = self.make_branch('branch')
319
319
tree = branch.create_checkout('tree', lightweight=True)
320
tree.commit('one', rev_id=b'rev-1')
320
tree.commit('one', rev_id='rev-1')
321
321
self.run_bzr('switch --create-branch ../branch2', working_dir='tree')
322
322
tree = WorkingTree.open('tree')
323
323
self.assertEndsWith(tree.branch.base, '/branch2/')
325
325
def test_create_branch_local(self):
326
326
branch = self.make_branch('branch')
327
327
tree = branch.create_checkout('tree', lightweight=True)
328
tree.commit('one', rev_id=b'rev-1')
328
tree.commit('one', rev_id='rev-1')
329
329
self.run_bzr('switch --create-branch branch2', working_dir='tree')
330
330
tree = WorkingTree.open('tree')
331
331
# The new branch should have been created at the same level as
335
335
def test_create_branch_short_name(self):
336
336
branch = self.make_branch('branch')
337
337
tree = branch.create_checkout('tree', lightweight=True)
338
tree.commit('one', rev_id=b'rev-1')
338
tree.commit('one', rev_id='rev-1')
339
339
self.run_bzr('switch -b branch2', working_dir='tree')
340
340
tree = WorkingTree.open('tree')
341
341
# The new branch should have been created at the same level as
386
386
# create a source branch
387
387
a_tree = self.make_branch_and_tree('a')
388
self.build_tree_contents([('a/a', b'initial\n')])
388
self.build_tree_contents([('a/a', 'initial\n')])
390
390
a_tree.commit(message='initial')
392
392
# clone and add a differing revision
393
393
b_tree = a_tree.controldir.sprout('b').open_workingtree()
394
self.build_tree_contents([('b/a', b'initial\nmore\n')])
394
self.build_tree_contents([('b/a', 'initial\nmore\n')])
395
395
b_tree.commit(message='more')
397
397
self.run_bzr('checkout --lightweight a checkout')
529
529
self.assertPathDoesNotExist('checkout/a')
530
530
self.run_bzr(['switch', '-d', 'checkout', 'orig'])
531
531
self.assertPathDoesNotExist('checkout/a')
534
class TestSwitchStandAloneCorruption(TestCaseWithTransport):
536
def test_empty_tree_switch(self):
537
"""switch . on an empty tree gets infinite recursion
539
Inspired by: https://bugs.launchpad.net/bzr/+bug/1018628
541
self.script_runner = script.ScriptRunner()
542
self.script_runner.run_script(self, '''
544
Created a standalone tree (format: 2a)
546
2>brz: ERROR: switching would create a branch reference loop. Use the "bzr up" command to switch to a different revision.
549
def test_switch_on_previous_rev(self):
550
"""switch to previous rev in a standalone directory
552
Inspired by: https://bugs.launchpad.net/brz/+bug/1018628
554
self.script_runner = script.ScriptRunner()
555
self.script_runner.run_script(self, '''
557
Created a standalone tree (format: 2a)
558
$ brz commit -m 1 --unchanged
559
$ brz commit -m 2 --unchanged
561
2>brz: ERROR: switching would create a branch reference loop. Use the "bzr up" command to switch to a different revision.''',
562
null_output_matches_anything=True)
564
def test_switch_create_colo_locks_repo_path(self):
565
self.script_runner = script.ScriptRunner()
566
self.script_runner.run_script(self, '''
570
Created a standalone tree (format: 2a)
571
$ echo A > a && brz add a && brz commit -m A
578
''', null_output_matches_anything=True)