/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1713.2.1 by Robert Collins
Some tests for WorkingTree.is_ignored so it can be refactored with confidence.
1
# (C) 2006 Canonical Ltd
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
19
20
21
class TestIsIgnored(TestCaseWithWorkingTree):
22
23
    def test_is_ignored(self):
24
        tree = self.make_branch_and_tree('.')
25
        # this will break if a tree changes the ignored format. That is fine
26
        # because at the moment tree format is orthogonal to user data, and
27
        # .bzrignore is user data so must not be changed by a tree format.
28
        self.build_tree_contents([
29
            ('.bzrignore', './rootdir\nrandomfile*\npath/from/ro?t\n')])
30
        # is_ignored returns the matching ignore regex when a path is ignored.
31
        # we check some expected matches for each rule, and one or more
32
        # relevant not-matches that look plausible as cases for bugs.
33
        self.assertEqual('./rootdir', tree.is_ignored('rootdir'))
34
        self.assertEqual(None, tree.is_ignored('foo/rootdir'))
1713.2.3 by Robert Collins
Combine ignore rules into a single regex preventing pathological behaviour during add.
35
        self.assertEqual(None, tree.is_ignored('rootdirtrailer'))
1713.2.1 by Robert Collins
Some tests for WorkingTree.is_ignored so it can be refactored with confidence.
36
        self.assertEqual('randomfile*', tree.is_ignored('randomfile'))
37
        self.assertEqual('randomfile*', tree.is_ignored('randomfiles'))
38
        self.assertEqual('randomfile*', tree.is_ignored('foo/randomfiles'))
39
        self.assertEqual(None, tree.is_ignored('randomfil'))
40
        self.assertEqual(None, tree.is_ignored('foo/randomfil'))
41
        self.assertEqual("path/from/ro?t", tree.is_ignored('path/from/root'))
42
        self.assertEqual("path/from/ro?t", tree.is_ignored('path/from/roat'))
43
        self.assertEqual(None, tree.is_ignored('roat'))