~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2012-02-22 13:39:51 UTC
  • mfrom: (6470.1.1 less-inventory-use-2)
  • Revision ID: pqm@pqm.ubuntu.com-20120222133951-cqvnnx710wox7905
(jelmer) Use inventories directly in fewer places. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""Black-box tests for bzr rmbranch."""
19
19
 
20
20
from bzrlib import (
21
 
    controldir,
 
21
    bzrdir,
22
22
    )
23
23
from bzrlib.tests import (
24
24
    TestCaseWithTransport,
28
28
 
29
29
class TestRemoveBranch(TestCaseWithTransport):
30
30
 
31
 
    def example_tree(self, path='.', format=None):
 
31
    def example_branch(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
 
        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')
47
 
        dir = controldir.ControlDir.open('a')
 
43
        self.example_branch('a')
 
44
        self.run_bzr('rmbranch a')
 
45
        dir = bzrdir.BzrDir.open('a')
48
46
        self.assertFalse(dir.has_branch())
49
47
        self.assertPathExists('a/hello')
50
48
        self.assertPathExists('a/goodbye')
51
49
 
52
50
    def test_no_branch(self):
53
 
        # No branch in the current directory.
 
51
        # No branch in the current directory. 
54
52
        self.make_repository('a')
55
53
        self.run_bzr_error(['Not a branch'],
56
54
            'rmbranch a')
57
55
 
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 = controldir.ControlDir.open('a')
64
 
        self.assertFalse(dir.has_branch())
65
 
 
66
56
    def test_no_arg(self):
67
57
        # location argument defaults to current directory
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')
72
 
        dir = controldir.ControlDir.open('a')
 
58
        self.example_branch('a')
 
59
        self.run_bzr('rmbranch', working_dir='a')
 
60
        dir = bzrdir.BzrDir.open('a')
73
61
        self.assertFalse(dir.has_branch())
74
62
 
75
63
    def test_remove_colo(self):
76
64
        # Remove a colocated branch.
77
 
        tree = self.example_tree('a')
 
65
        tree = self.example_branch('a', format='development-colo')
78
66
        tree.bzrdir.create_branch(name="otherbranch")
79
67
        self.assertTrue(tree.bzrdir.has_branch('otherbranch'))
80
68
        self.run_bzr('rmbranch %s,branch=otherbranch' % tree.bzrdir.user_url)
81
 
        dir = controldir.ControlDir.open('a')
82
 
        self.assertFalse(dir.has_branch('otherbranch'))
83
 
        self.assertTrue(dir.has_branch())
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 = controldir.ControlDir.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'))
 
69
        dir = bzrdir.BzrDir.open('a')
 
70
        self.assertFalse(dir.has_branch('otherbranch'))
 
71
        self.assertTrue(dir.has_branch())
105
72
 
106
73
 
107
74
class TestSmartServerRemoveBranch(TestCaseWithTransport):
116
83
        # being too low. If rpc_count increases, more network roundtrips have
117
84
        # become necessary for this use case. Please do not adjust this number
118
85
        # upwards without agreement from bzr's network support maintainers.
119
 
        self.assertLength(5, self.hpss_calls)
 
86
        self.assertLength(2, self.hpss_calls)
120
87
        self.assertLength(1, self.hpss_connections)
121
88
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)