1
# (C) 2006 Canonical Ltd
2
# Authors: Robert Collins <robert.collins@canonical.com>
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.
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.
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
18
from cStringIO import StringIO
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,
38
class TestIsControlFilename(TestCaseWithWorkingTree):
40
def validate_tree_is_controlfilename(self, tree):
41
"""check that 'tree' obeys the contract for is_control_filename."""
42
bzrdirname = basename(tree.bzrdir.transport.base[:-1])
43
self.assertTrue(tree.is_control_filename(bzrdirname))
44
self.assertTrue(tree.is_control_filename(bzrdirname + '/subdir'))
45
self.assertFalse(tree.is_control_filename('dir/' + bzrdirname))
46
self.assertFalse(tree.is_control_filename('dir/' + bzrdirname + '/sub'))
48
def test_dotbzr_is_control_in_cwd(self):
49
tree = self.make_branch_and_tree('.')
50
self.validate_tree_is_controlfilename(tree)
52
def test_dotbzr_is_control_in_subdir(self):
53
tree = self.make_branch_and_tree('subdir')
54
self.validate_tree_is_controlfilename(tree)