49
50
self.assertContainsRe(err, 'Switched to branch: .*/branch2.\n')
50
51
self.assertEqual('', out)
53
def _test_switch_nick(self, lightweight):
54
"""Check that the nick gets switched too."""
55
tree1 = self.make_branch_and_tree('branch1')
56
tree2 = self.make_branch_and_tree('branch2')
57
tree2.pull(tree1.branch)
58
checkout = tree1.branch.create_checkout('checkout',
59
lightweight=lightweight)
60
self.assertEqual(checkout.branch.nick, tree1.branch.nick)
61
self.assertEqual(checkout.branch.get_config().has_explicit_nickname(),
63
self.run_bzr('switch branch2', working_dir='checkout')
65
# we need to get the tree again, otherwise we don't get the new branch
66
checkout = WorkingTree.open('checkout')
67
self.assertEqual(checkout.branch.nick, tree2.branch.nick)
68
self.assertEqual(checkout.branch.get_config().has_explicit_nickname(),
52
71
def test_switch_nick(self):
72
self._test_switch_nick(lightweight=False)
74
def test_switch_nick_lightweight(self):
75
self._test_switch_nick(lightweight=True)
77
def _test_switch_explicit_nick(self, lightweight):
53
78
"""Check that the nick gets switched too."""
54
79
tree1 = self.make_branch_and_tree('branch1')
55
80
tree2 = self.make_branch_and_tree('branch2')
56
81
tree2.pull(tree1.branch)
57
checkout = tree1.branch.create_checkout('checkout', lightweight=True)
58
self.run_bzr(['switch', 'branch2'], working_dir='checkout')
59
self.assertEqual(tree1.branch.nick, tree2.branch.nick)
82
checkout = tree1.branch.create_checkout('checkout',
83
lightweight=lightweight)
84
self.assertEqual(checkout.branch.nick, tree1.branch.nick)
85
checkout.branch.nick = "explicit_nick"
86
self.assertEqual(checkout.branch.nick, "explicit_nick")
87
self.assertEqual(checkout.branch.get_config()._get_explicit_nickname(),
89
self.run_bzr('switch branch2', working_dir='checkout')
91
# we need to get the tree again, otherwise we don't get the new branch
92
checkout = WorkingTree.open('checkout')
93
self.assertEqual(checkout.branch.nick, tree2.branch.nick)
94
self.assertEqual(checkout.branch.get_config()._get_explicit_nickname(),
97
def test_switch_explicit_nick(self):
98
self._test_switch_explicit_nick(lightweight=False)
100
def test_switch_explicit_nick_lightweight(self):
101
self._test_switch_explicit_nick(lightweight=True)
61
103
def test_switch_finds_relative_branch(self):
62
104
"""Switch will find 'foo' relative to the branch the checkout is of."""