537
537
Using shared repository: ...
540
def assertParentCorrect(self, branch, expected_parent):
540
def assertParentCorrect(self, branch, expected_parent, name):
541
541
"""Verify that the parent is not None and is set correctly."""
542
542
actual_parent = branch.get_parent()
543
self.assertIsNot(actual_parent, None, "Parent not set")
543
self.assertIsNot(actual_parent, None, name + "Parent not set")
544
544
expected = urlutils.strip_trailing_slash(urlutils.normalize_url(expected_parent))
545
545
actual = urlutils.strip_trailing_slash(urlutils.normalize_url(actual_parent))
546
self.assertEquals(expected, actual, "Parent set incorrectly")
546
self.assertEquals(expected, actual, name + "Parent set incorrectly")
548
548
def _create_checkout_and_branch(self, option, suffix):
549
549
self.script_runner.run_script(self, '''
555
555
2>Switched to branch:...branched_%(suffix)s...
558
return branch.Branch.open_containing('work_%(suffix)s_branch' % locals())[0]
558
bound_branch = branch.Branch.open_containing('work_%(suffix)s_branch' % locals())[0]
559
master_branch = branch.Branch.open_containing('repo/branched_%(suffix)s' % locals())[0]
560
return (bound_branch, master_branch)
560
562
def test_branch_switch_parent_lightweight(self):
561
563
"""Verify parent directory for lightweight checkout using bzr branch --switch."""
562
b = self._create_checkout_and_branch(option='--lightweight', suffix='lw')
563
self.assertParentCorrect(b, urlutils.local_path_to_url('repo/trunk'))
564
bb, mb = self._create_checkout_and_branch(option='--lightweight', suffix='lw')
565
self.assertParentCorrect(bb, urlutils.local_path_to_url('repo/trunk'), "Checkout")
566
self.assertParentCorrect(mb, urlutils.local_path_to_url('repo/trunk'), "Master Branch")
565
568
def test_branch_switch_parent_heavyweight(self):
566
569
"""Verify parent directory for heavyweight checkout using bzr branch --switch."""
567
b = self._create_checkout_and_branch(option='', suffix='hw')
568
self.assertParentCorrect(b, urlutils.local_path_to_url('repo/trunk'))
570
bb, mb = self._create_checkout_and_branch(option='', suffix='hw')
571
self.assertParentCorrect(bb, urlutils.local_path_to_url('repo/trunk'), "Bound Branch")
572
self.assertParentCorrect(mb, urlutils.local_path_to_url('repo/trunk'), "Master Branch")