/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4991.1.1 by Jelmer Vernooij
Add rmbranch command.
1
# Copyright (C) 2010 Canonical Ltd
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17
18
"""Black-box tests for bzr rmbranch."""
19
20
from bzrlib import (
21
    bzrdir,
4991.1.3 by Jelmer Vernooij
Name command remove-branch, rmbranch as alias.
22
    )
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
23
from bzrlib.tests import (
24
    TestCaseWithTransport,
4991.1.3 by Jelmer Vernooij
Name command remove-branch, rmbranch as alias.
25
    )
4991.1.1 by Jelmer Vernooij
Add rmbranch command.
26
27
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
28
class TestRemoveBranch(TestCaseWithTransport):
4991.1.1 by Jelmer Vernooij
Add rmbranch command.
29
6240.4.1 by Jelmer Vernooij
Support removing colocated branches in 'bzr rmbranch'.
30
    def example_branch(self, path='.', format=None):
31
        tree = self.make_branch_and_tree(path, format=format)
4991.1.1 by Jelmer Vernooij
Add rmbranch command.
32
        self.build_tree_contents([(path + '/hello', 'foo')])
33
        tree.add('hello')
34
        tree.commit(message='setup')
35
        self.build_tree_contents([(path + '/goodbye', 'baz')])
36
        tree.add('goodbye')
37
        tree.commit(message='setup')
6240.4.1 by Jelmer Vernooij
Support removing colocated branches in 'bzr rmbranch'.
38
        return tree
4991.1.1 by Jelmer Vernooij
Add rmbranch command.
39
40
    def test_remove_local(self):
4991.1.2 by Jelmer Vernooij
Fix comments
41
        # Remove a local branch.
4991.1.1 by Jelmer Vernooij
Add rmbranch command.
42
        self.example_branch('a')
43
        self.run_bzr('rmbranch a')
44
        dir = bzrdir.BzrDir.open('a')
45
        self.assertFalse(dir.has_branch())
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
46
        self.assertPathExists('a/hello')
47
        self.assertPathExists('a/goodbye')
4991.1.1 by Jelmer Vernooij
Add rmbranch command.
48
49
    def test_no_branch(self):
50
        # No branch in the current directory. 
51
        self.make_repository('a')
52
        self.run_bzr_error(['Not a branch'],
53
            'rmbranch a')
54
55
    def test_no_arg(self):
56
        # location argument defaults to current directory
57
        self.example_branch('a')
58
        self.run_bzr('rmbranch', working_dir='a')
59
        dir = bzrdir.BzrDir.open('a')
60
        self.assertFalse(dir.has_branch())
6240.4.1 by Jelmer Vernooij
Support removing colocated branches in 'bzr rmbranch'.
61
62
    def test_remove_colo(self):
63
        # Remove a colocated branch.
64
        tree = self.example_branch('a', format='development-colo')
65
        tree.bzrdir.create_branch(name="otherbranch")
66
        self.assertTrue(tree.bzrdir.has_branch('otherbranch'))
67
        self.run_bzr('rmbranch %s,branch=otherbranch' % tree.bzrdir.user_url)
68
        dir = bzrdir.BzrDir.open('a')
69
        self.assertFalse(dir.has_branch('otherbranch'))
70
        self.assertTrue(dir.has_branch())
6240.4.5 by Martin Packman
Merge bzr.dev to resolve conflict in bb.test_rmbranch
71
6283.1.6 by Jelmer Vernooij
Add hpss call count for 'bzr rmbranch'.
72
73
class TestSmartServerRemoveBranch(TestCaseWithTransport):
74
75
    def test_simple_remove_branch(self):
76
        self.setup_smart_server_with_call_log()
77
        self.make_branch('branch')
78
        self.reset_smart_call_log()
79
        out, err = self.run_bzr(['rmbranch', self.get_url('branch')])
80
        # This figure represent the amount of work to perform this use case. It
81
        # is entirely ok to reduce this number if a test fails due to rpc_count
82
        # being too low. If rpc_count increases, more network roundtrips have
83
        # become necessary for this use case. Please do not adjust this number
84
        # upwards without agreement from bzr's network support maintainers.
6266.4.7 by Jelmer Vernooij
Merge bzr.dev, fix call count for 'bzr rmbranch'.
85
        self.assertLength(5, self.hpss_calls)