/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_switch.py

  • Committer: Aaron Bentley
  • Date: 2008-11-03 18:59:14 UTC
  • mfrom: (3818 +trunk)
  • mto: (0.16.99 shelf-ui)
  • mto: This revision was merged to the branch mainline in revision 3820.
  • Revision ID: aaron@aaronbentley.com-20081103185914-inz25vtsiowydw1p
Merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import os
22
22
 
 
23
from bzrlib.workingtree import WorkingTree
23
24
from bzrlib.tests.blackbox import ExternalBase
24
25
 
25
26
 
49
50
        self.assertContainsRe(err, 'Switched to branch: .*/branch2.\n')
50
51
        self.assertEqual('', out)
51
52
 
 
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(),
 
62
            False)
 
63
        self.run_bzr('switch branch2', working_dir='checkout')
 
64
 
 
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(),
 
69
            False)
 
70
 
 
71
    def test_switch_nick(self):
 
72
        self._test_switch_nick(lightweight=False)
 
73
 
 
74
    def test_switch_nick_lightweight(self):
 
75
        self._test_switch_nick(lightweight=True)
 
76
 
 
77
    def _test_switch_explicit_nick(self, lightweight):
 
78
        """Check that the nick gets switched too."""
 
79
        tree1 = self.make_branch_and_tree('branch1')
 
80
        tree2 = self.make_branch_and_tree('branch2')
 
81
        tree2.pull(tree1.branch)
 
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(),
 
88
            "explicit_nick")
 
89
        self.run_bzr('switch branch2', working_dir='checkout')
 
90
 
 
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(),
 
95
            tree2.branch.nick)
 
96
 
 
97
    def test_switch_explicit_nick(self):
 
98
        self._test_switch_explicit_nick(lightweight=False)
 
99
 
 
100
    def test_switch_explicit_nick_lightweight(self):
 
101
        self._test_switch_explicit_nick(lightweight=True)
 
102
 
52
103
    def test_switch_finds_relative_branch(self):
53
 
        """Switch will find 'foo' relative to the branch that the checkout is of."""
 
104
        """Switch will find 'foo' relative to the branch the checkout is of."""
54
105
        self.build_tree(['repo/'])
55
106
        tree1 = self.make_branch_and_tree('repo/brancha')
56
107
        tree1.commit('foo')