516
518
2>The command 'bzr %(command)s' has been deprecated in bzr 2.4. Please use 'bzr branch' instead.
517
519
2>bzr: ERROR: Not a branch...
523
class TestBranchParentLocation(TestCaseWithTransport):
526
"""Set up a repository and branch ready for testing."""
527
super(TestBranchParentLocation, self).setUp()
528
self.script_runner = script.ScriptRunner()
529
self.script_runner.run_script(self, '''
530
$ bzr init-repo --no-trees repo
533
shared repository: repo
534
$ bzr init repo/trunk
535
Created a repository branch...
536
Using shared repository: ...
539
def assertParentCorrect(self, branch, expected_parent):
540
"""Verify that the parent is not None and is set correctly.
542
@param branch: Branch for which to check parent.
543
@param expected_parent: Expected parent as a list of strings for each component:
544
each element in the list is compared.
546
parent = branch.get_parent()
547
self.assertIsNot(parent, None, "Parent not set")
548
# Get the last 'n' path elements from the parent where 'n' is the length of
549
# the expected_parent, so if ['repo', 'branch'] is passed, get the last two
550
# components for comparison.
551
actual_parent = osutils.splitpath(parent.rstrip(r'\/'))[-len(expected_parent):]
552
self.assertEquals(expected_parent, actual_parent, "Parent set incorrectly")
554
def test_branch_switch_parent_lightweight(self):
555
"""Verify parent directory for lightweight checkout using bzr branch --switch."""
556
self.script_runner.run_script(self, '''
557
$ bzr checkout --lightweight repo/trunk work_lw_branch
559
$ bzr branch --switch ../repo/trunk ../repo/branched_lw
560
2>Branched 0 revision(s).
561
2>Tree is up to date at revision 0.
562
2>Switched to branch:...branched_lw...
564
b = branch.Branch.open_containing('work_lw_branch')[0]
565
self.assertParentCorrect(b, ['repo','trunk'])
567
def test_branch_switch_parent_heavyweight(self):
568
"""Verify parent directory for heavyweight checkout using bzr branch --switch."""
569
self.script_runner.run_script(self, '''
570
$ bzr checkout repo/trunk work_hw_branch
572
$ bzr branch --switch ../repo/trunk ../repo/branched_hw
573
2>Branched 0 revision(s).
574
2>Tree is up to date at revision 0.
575
2>Switched to branch:...branched_hw...
577
b = branch.Branch.open_containing('work_hw_branch')[0]
578
self.assertParentCorrect(b, ['repo','trunk'])