/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 breezy/tests/blackbox/test_rmbranch.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from breezy.tests import (
24
24
    TestCaseWithTransport,
25
25
    )
 
26
from breezy.tests.matchers import ContainsNoVfsCalls
26
27
 
27
28
 
28
29
class TestRemoveBranch(TestCaseWithTransport):
29
30
 
30
31
    def example_tree(self, path='.', format=None):
31
32
        tree = self.make_branch_and_tree(path, format=format)
32
 
        self.build_tree_contents([(path + '/hello', b'foo')])
 
33
        self.build_tree_contents([(path + '/hello', 'foo')])
33
34
        tree.add('hello')
34
35
        tree.commit(message='setup')
35
 
        self.build_tree_contents([(path + '/goodbye', b'baz')])
 
36
        self.build_tree_contents([(path + '/goodbye', 'baz')])
36
37
        tree.add('goodbye')
37
38
        tree.commit(message='setup')
38
39
        return tree
41
42
        # Remove a local branch.
42
43
        tree = self.example_tree('a')
43
44
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
44
 
                           'rmbranch a')
 
45
            'rmbranch a')
45
46
        self.run_bzr('rmbranch --force a')
46
47
        dir = controldir.ControlDir.open('a')
47
48
        self.assertFalse(dir.has_branch())
51
52
    def test_no_branch(self):
52
53
        # No branch in the current directory.
53
54
        self.make_repository('a')
54
 
        self.run_bzr_error(['Not a branch'], 'rmbranch a')
 
55
        self.run_bzr_error(['Not a branch'],
 
56
            'rmbranch a')
55
57
 
56
58
    def test_no_tree(self):
57
59
        # removing the active branch is possible if there is no tree
58
60
        tree = self.example_tree('a')
59
 
        tree.controldir.destroy_workingtree()
 
61
        tree.bzrdir.destroy_workingtree()
60
62
        self.run_bzr('rmbranch', working_dir='a')
61
63
        dir = controldir.ControlDir.open('a')
62
64
        self.assertFalse(dir.has_branch())
65
67
        # location argument defaults to current directory
66
68
        self.example_tree('a')
67
69
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
68
 
                           'rmbranch a')
 
70
            'rmbranch a')
69
71
        self.run_bzr('rmbranch --force', working_dir='a')
70
72
        dir = controldir.ControlDir.open('a')
71
73
        self.assertFalse(dir.has_branch())
73
75
    def test_remove_colo(self):
74
76
        # Remove a colocated branch.
75
77
        tree = self.example_tree('a')
76
 
        tree.controldir.create_branch(name="otherbranch")
77
 
        self.assertTrue(tree.controldir.has_branch('otherbranch'))
78
 
        self.run_bzr('rmbranch %s,branch=otherbranch' %
79
 
                     tree.controldir.user_url)
 
78
        tree.bzrdir.create_branch(name="otherbranch")
 
79
        self.assertTrue(tree.bzrdir.has_branch('otherbranch'))
 
80
        self.run_bzr('rmbranch %s,branch=otherbranch' % tree.bzrdir.user_url)
80
81
        dir = controldir.ControlDir.open('a')
81
82
        self.assertFalse(dir.has_branch('otherbranch'))
82
83
        self.assertTrue(dir.has_branch())
84
85
    def test_remove_colo_directory(self):
85
86
        # Remove a colocated branch.
86
87
        tree = self.example_tree('a')
87
 
        tree.controldir.create_branch(name="otherbranch")
88
 
        self.assertTrue(tree.controldir.has_branch('otherbranch'))
89
 
        self.run_bzr('rmbranch otherbranch -d %s' % tree.controldir.user_url)
 
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)
90
91
        dir = controldir.ControlDir.open('a')
91
92
        self.assertFalse(dir.has_branch('otherbranch'))
92
93
        self.assertTrue(dir.has_branch())
93
94
 
94
95
    def test_remove_active_colo_branch(self):
95
96
        # Remove a colocated branch.
96
 
        dir = self.make_repository('a').controldir
 
97
        dir = self.make_repository('a').bzrdir
97
98
        branch = dir.create_branch('otherbranch')
98
99
        branch.create_checkout('a')
99
100
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
100
 
                           'rmbranch otherbranch -d %s' % branch.controldir.user_url)
 
101
            'rmbranch otherbranch -d %s' % branch.bzrdir.user_url)
101
102
        self.assertTrue(dir.has_branch('otherbranch'))
102
 
        self.run_bzr('rmbranch --force otherbranch -d %s' %
103
 
                     branch.controldir.user_url)
 
103
        self.run_bzr('rmbranch --force otherbranch -d %s' % branch.bzrdir.user_url)
104
104
        self.assertFalse(dir.has_branch('otherbranch'))
105
105
 
 
106
 
 
107
class TestSmartServerRemoveBranch(TestCaseWithTransport):
 
108
 
 
109
    def test_simple_remove_branch(self):
 
110
        self.setup_smart_server_with_call_log()
 
111
        self.make_branch('branch')
 
112
        self.reset_smart_call_log()
 
113
        out, err = self.run_bzr(['rmbranch', self.get_url('branch')])
 
114
        # This figure represent the amount of work to perform this use case. It
 
115
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
116
        # being too low. If rpc_count increases, more network roundtrips have
 
117
        # become necessary for this use case. Please do not adjust this number
 
118
        # upwards without agreement from bzr's network support maintainers.
 
119
        self.assertLength(5, self.hpss_calls)
 
120
        self.assertLength(1, self.hpss_connections)
 
121
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)