~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-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
 
 
19
 
"""Tests of the 'bzr clean-tree' command."""
20
 
 
21
 
 
22
 
import os
23
 
 
24
 
from bzrlib import ignores
25
 
from bzrlib.tests import TestCaseWithTransport
26
 
 
27
 
 
28
 
class TestBzrTools(TestCaseWithTransport):
29
 
 
30
 
    @staticmethod
31
 
    def touch(filename):
32
 
        my_file = open(filename, 'wb')
33
 
        try:
34
 
            my_file.write('')
35
 
        finally:
36
 
            my_file.close()
37
 
 
38
 
    def test_clean_tree(self):
39
 
        self.run_bzr('init')
40
 
        self.run_bzr('ignore *~')
41
 
        self.run_bzr('ignore *.pyc')
42
 
        self.touch('name')
43
 
        self.touch('name~')
44
 
        self.failUnlessExists('name~')
45
 
        self.touch('name.pyc')
46
 
        self.run_bzr('clean-tree --force')
47
 
        self.failUnlessExists('name~')
48
 
        self.failIfExists('name')
49
 
        self.touch('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')
59
 
        self.touch('name')
60
 
        self.touch('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')
66
 
 
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')
81
 
 
82
 
    def test_clean_tree_directory(self):
83
 
        """Test --directory option"""
84
 
        tree = self.make_branch_and_tree('a')
85
 
        self.build_tree(['a/added', 'a/unknown', 'a/ignored'])
86
 
        tree.add('added')
87
 
        self.run_bzr('clean-tree -d a --unknown --ignored --force')
88
 
        self.failIfExists('a/unknown')
89
 
        self.failIfExists('a/ignored')
90
 
        self.failUnlessExists('a/added')