1
# Copyright (C) 2005, 2006 by 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""UI tests for bzr ignore."""
20
from cStringIO import StringIO
26
from bzrlib.branch import Branch
27
import bzrlib.bzrdir as bzrdir
28
from bzrlib.errors import BzrCommandError
29
from bzrlib.osutils import (
35
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
36
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
37
from bzrlib.tests.blackbox import ExternalBase
38
from bzrlib.workingtree import WorkingTree
41
class TestCommands(ExternalBase):
43
def test_ignore_patterns(self):
45
self.assertEquals(self.capture('unknowns'), '')
47
self.build_tree_contents(
48
[('foo.tmp', 'tmp files are ignored'),
49
('.bzrignore', '*.tmp'),
51
self.run_bzr('add', '.bzrignore')
52
self.assertEquals(self.capture('unknowns'), '')
54
file('foo.c', 'wt').write('int main() {}')
55
self.assertEquals(self.capture('unknowns'), 'foo.c\n')
57
self.runbzr(['add', 'foo.c'])
58
self.assertEquals(self.capture('unknowns'), '')
60
# 'ignore' works when creating the .bzrignore file
61
file('foo.blah', 'wt').write('blah')
62
self.assertEquals(self.capture('unknowns'), 'foo.blah\n')
63
self.runbzr('ignore *.blah')
64
self.assertEquals(self.capture('unknowns'), '')
65
self.assertEquals(file('.bzrignore', 'rU').read(), '*.tmp\n*.blah\n')
67
# 'ignore' works when then .bzrignore file already exists
68
file('garh', 'wt').write('garh')
69
self.assertEquals(self.capture('unknowns'), 'garh\n')
70
self.runbzr('ignore garh')
71
self.assertEquals(self.capture('unknowns'), '')
72
self.assertEquals(file('.bzrignore', 'rU').read(), '*.tmp\n*.blah\ngarh\n')
74
def test_ignore_old_defaults(self):
75
out, err = self.run_bzr('ignore', '--old-default-rules')
76
self.assertContainsRe(out, 'CVS')
77
self.assertEqual('', err)