1
# Copyright (C) 2005, 2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
"""Tests of the 'bzr clean-tree' command."""
24
from bzrlib import ignores
25
from bzrlib.tests import TestCaseWithTransport
28
class TestBzrTools(TestCaseWithTransport):
32
my_file = open(filename, 'wb')
38
def test_clean_tree(self):
40
self.run_bzr('ignore *~')
41
self.run_bzr('ignore *.pyc')
44
self.failUnlessExists('name~')
45
self.touch('name.pyc')
46
self.run_bzr('clean-tree --force')
47
self.failUnlessExists('name~')
48
self.failIfExists('name')
50
self.run_bzr('clean-tree --detritus --force')
51
self.failUnlessExists('name')
52
self.failIfExists('name~')
53
self.failUnlessExists('name.pyc')
54
self.run_bzr('clean-tree --ignored --force')
55
self.failUnlessExists('name')
56
self.failIfExists('name.pyc')
57
self.run_bzr('clean-tree --unknown --force')
58
self.failIfExists('name')
61
self.touch('name.pyc')
62
self.run_bzr('clean-tree --unknown --ignored --force')
63
self.failIfExists('name')
64
self.failIfExists('name~')
65
self.failIfExists('name.pyc')
67
def test_clean_tree_nested_bzrdir(self):
68
# clean-tree should not blindly delete nested bzrdirs (branches)
69
# bug https://bugs.launchpad.net/bzr/+bug/572098
70
# so it will play well with scmproj/bzr-externals plugins.
71
wt1 = self.make_branch_and_tree('.')
72
wt2 = self.make_branch_and_tree('foo')
73
wt3 = self.make_branch_and_tree('bar')
74
ignores.tree_ignores_add_patterns(wt1, ['./foo'])
75
self.run_bzr(['clean-tree', '--unknown', '--force'])
76
self.failUnlessExists('foo')
77
self.failUnlessExists('bar')
78
self.run_bzr(['clean-tree', '--ignored', '--force'])
79
self.failUnlessExists('foo')
80
self.failUnlessExists('bar')