~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2013-05-19 14:29:37 UTC
  • mfrom: (6437.63.9 2.5)
  • mto: (6437.63.10 2.5)
  • mto: This revision was merged to the branch mainline in revision 6575.
  • Revision ID: john@arbash-meinel.com-20130519142937-21ykz2n2y2f22za9
Merge in the actual 2.5 branch. It seems I failed before

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
class TestRemoveBranch(TestCaseWithTransport):
30
30
 
31
 
    def example_branch(self, path='.', format=None):
 
31
    def example_tree(self, path='.', format=None):
32
32
        tree = self.make_branch_and_tree(path, format=format)
33
33
        self.build_tree_contents([(path + '/hello', 'foo')])
34
34
        tree.add('hello')
40
40
 
41
41
    def test_remove_local(self):
42
42
        # Remove a local branch.
43
 
        self.example_branch('a')
44
 
        self.run_bzr('rmbranch a')
 
43
        tree = self.example_tree('a')
 
44
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
 
45
            'rmbranch a')
 
46
        self.run_bzr('rmbranch --force a')
45
47
        dir = bzrdir.BzrDir.open('a')
46
48
        self.assertFalse(dir.has_branch())
47
49
        self.assertPathExists('a/hello')
48
50
        self.assertPathExists('a/goodbye')
49
51
 
50
52
    def test_no_branch(self):
51
 
        # No branch in the current directory. 
 
53
        # No branch in the current directory.
52
54
        self.make_repository('a')
53
55
        self.run_bzr_error(['Not a branch'],
54
56
            'rmbranch a')
55
57
 
 
58
    def test_no_tree(self):
 
59
        # removing the active branch is possible if there is no tree
 
60
        tree = self.example_tree('a')
 
61
        tree.bzrdir.destroy_workingtree()
 
62
        self.run_bzr('rmbranch', working_dir='a')
 
63
        dir = bzrdir.BzrDir.open('a')
 
64
        self.assertFalse(dir.has_branch())
 
65
 
56
66
    def test_no_arg(self):
57
67
        # location argument defaults to current directory
58
 
        self.example_branch('a')
59
 
        self.run_bzr('rmbranch', working_dir='a')
 
68
        self.example_tree('a')
 
69
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
 
70
            'rmbranch a')
 
71
        self.run_bzr('rmbranch --force', working_dir='a')
60
72
        dir = bzrdir.BzrDir.open('a')
61
73
        self.assertFalse(dir.has_branch())
62
74
 
63
75
    def test_remove_colo(self):
64
76
        # Remove a colocated branch.
65
 
        tree = self.example_branch('a', format='development-colo')
 
77
        tree = self.example_tree('a')
66
78
        tree.bzrdir.create_branch(name="otherbranch")
67
79
        self.assertTrue(tree.bzrdir.has_branch('otherbranch'))
68
80
        self.run_bzr('rmbranch %s,branch=otherbranch' % tree.bzrdir.user_url)
70
82
        self.assertFalse(dir.has_branch('otherbranch'))
71
83
        self.assertTrue(dir.has_branch())
72
84
 
 
85
    def test_remove_colo_directory(self):
 
86
        # Remove a colocated branch.
 
87
        tree = self.example_tree('a')
 
88
        tree.bzrdir.create_branch(name="otherbranch")
 
89
        self.assertTrue(tree.bzrdir.has_branch('otherbranch'))
 
90
        self.run_bzr('rmbranch otherbranch -d %s' % tree.bzrdir.user_url)
 
91
        dir = bzrdir.BzrDir.open('a')
 
92
        self.assertFalse(dir.has_branch('otherbranch'))
 
93
        self.assertTrue(dir.has_branch())
 
94
 
 
95
    def test_remove_active_colo_branch(self):
 
96
        # Remove a colocated branch.
 
97
        dir = self.make_repository('a').bzrdir
 
98
        branch = dir.create_branch('otherbranch')
 
99
        branch.create_checkout('a')
 
100
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
 
101
            'rmbranch otherbranch -d %s' % branch.bzrdir.user_url)
 
102
        self.assertTrue(dir.has_branch('otherbranch'))
 
103
        self.run_bzr('rmbranch --force otherbranch -d %s' % branch.bzrdir.user_url)
 
104
        self.assertFalse(dir.has_branch('otherbranch'))
 
105
 
73
106
 
74
107
class TestSmartServerRemoveBranch(TestCaseWithTransport):
75
108
 
83
116
        # being too low. If rpc_count increases, more network roundtrips have
84
117
        # become necessary for this use case. Please do not adjust this number
85
118
        # upwards without agreement from bzr's network support maintainers.
86
 
        self.assertLength(2, self.hpss_calls)
 
119
        self.assertLength(5, self.hpss_calls)
87
120
        self.assertLength(1, self.hpss_connections)
88
121
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)