1
# Copyright (C) 2006 Canonical Ltd
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
"""Black-box tests for bzr remove-tree."""
22
from bzrlib.tests.blackbox import ExternalBase
25
class TestRemoveTree(ExternalBase):
28
super(TestRemoveTree, self).setUp()
29
self.tree = self.make_branch_and_tree('branch1')
30
self.build_tree(['branch1/foo'])
33
self.failUnlessExists('branch1/foo')
37
def test_remove_tree_original_branch(self):
39
self.run_bzr('remove-tree')
40
self.failIfExists('foo')
42
def test_remove_tree_original_branch_explicit(self):
43
self.run_bzr('remove-tree', 'branch1')
44
self.failIfExists('branch1/foo')
46
def test_remove_tree_sprouted_branch(self):
47
self.tree.bzrdir.sprout('branch2')
48
self.failUnlessExists('branch2/foo')
50
self.run_bzr('remove-tree')
51
self.failIfExists('foo')
53
def test_remove_tree_sprouted_branch_explicit(self):
54
self.tree.bzrdir.sprout('branch2')
55
self.failUnlessExists('branch2/foo')
56
self.run_bzr('remove-tree', 'branch2')
57
self.failIfExists('branch2/foo')
59
def test_remove_tree_checkout(self):
60
self.tree.branch.create_checkout('branch2', lightweight=False)
61
self.failUnlessExists('branch2/foo')
63
self.run_bzr('remove-tree')
64
self.failIfExists('foo')
66
self.failUnlessExists('branch1/foo')
68
def test_remove_tree_checkout_explicit(self):
69
self.tree.branch.create_checkout('branch2', lightweight=False)
70
self.failUnlessExists('branch2/foo')
71
self.run_bzr('remove-tree', 'branch2')
72
self.failIfExists('branch2/foo')
73
self.failUnlessExists('branch1/foo')
77
def test_remove_tree_lightweight_checkout(self):
78
self.tree.branch.create_checkout('branch2', lightweight=True)
79
self.failUnlessExists('branch2/foo')
81
output = self.run_bzr_error(
82
["You cannot remove the working tree from a lightweight checkout"],
83
'remove-tree', retcode=3)
84
self.failUnlessExists('foo')
86
self.failUnlessExists('branch1/foo')
88
def test_remove_tree_lightweight_checkout_explicit(self):
89
self.tree.branch.create_checkout('branch2', lightweight=True)
90
self.failUnlessExists('branch2/foo')
91
output = self.run_bzr(
92
["Cannot remove working tree from lightweight checkout"],
93
'remove-tree', 'branch2', retcode=3)
94
self.failUnlessExists('branch2/foo')
95
self.failUnlessExists('branch1/foo')
97
def test_remove_tree_empty_dir(self):
100
output = self.run_bzr(["Not a branch"],
101
'remove-tree', retcode=3)
103
def test_remove_tree_repeatedly(self):
104
self.run_bzr('remove-tree', 'branch1')
105
self.failIfExists('branch1/foo')
106
output = self.run_bzr_error(["No working tree to remove"],
107
'remove-tree', 'branch1', retcode=3)
109
def test_remove_tree_remote_path(self):
110
# TODO: I can't think of a way to implement this...