/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 cStringIO import StringIO
19
import os
20
21
import bzrlib
22
import bzrlib.branch
23
from bzrlib.branch import Branch
24
import bzrlib.bzrdir as bzrdir
25
from bzrlib.bzrdir import BzrDir
26
import bzrlib.errors as errors
27
from bzrlib.errors import NotBranchError, NotVersionedError
28
from bzrlib.osutils import basename
29
from bzrlib.tests import TestSkipped
30
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
31
from bzrlib.trace import mutter
32
from bzrlib.transport import get_transport
33
import bzrlib.workingtree as workingtree
34
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
35
                                WorkingTree)
36
37
38
class TestIsIgnored(TestCaseWithWorkingTree):
39
40
    def test_is_ignored(self):
41
        tree = self.make_branch_and_tree('.')
42
        # this will break if a tree changes the ignored format. That is fine
43
        # because at the moment tree format is orthogonal to user data, and
44
        # .bzrignore is user data so must not be changed by a tree format.
45
        self.build_tree_contents([
46
            ('.bzrignore', './rootdir\nrandomfile*\npath/from/ro?t\n')])
47
        # is_ignored returns the matching ignore regex when a path is ignored.
48
        # we check some expected matches for each rule, and one or more
49
        # relevant not-matches that look plausible as cases for bugs.
50
        self.assertEqual('./rootdir', tree.is_ignored('rootdir'))
51
        self.assertEqual(None, tree.is_ignored('foo/rootdir'))
52
        self.assertEqual('randomfile*', tree.is_ignored('randomfile'))
53
        self.assertEqual('randomfile*', tree.is_ignored('randomfiles'))
54
        self.assertEqual('randomfile*', tree.is_ignored('foo/randomfiles'))
55
        self.assertEqual(None, tree.is_ignored('randomfil'))
56
        self.assertEqual(None, tree.is_ignored('foo/randomfil'))
57
        self.assertEqual("path/from/ro?t", tree.is_ignored('path/from/root'))
58
        self.assertEqual("path/from/ro?t", tree.is_ignored('path/from/roat'))
59
        self.assertEqual(None, tree.is_ignored('roat'))