~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-07-07 15:22:42 UTC
  • mfrom: (1843 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1846.
  • Revision ID: john@arbash-meinel.com-20060707152242-a7b5e0afd64d9d5a
[merge] bzr.dev 1843

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2006 by 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""UI tests for bzr ignore."""
 
18
 
 
19
 
 
20
from cStringIO import StringIO
 
21
import os
 
22
import re
 
23
import sys
 
24
 
 
25
import bzrlib
 
26
from bzrlib.branch import Branch
 
27
import bzrlib.bzrdir as bzrdir
 
28
from bzrlib.errors import BzrCommandError
 
29
from bzrlib.osutils import (
 
30
    has_symlinks,
 
31
    pathjoin,
 
32
    rmtree,
 
33
    terminal_width,
 
34
    )
 
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
 
39
 
 
40
 
 
41
class TestCommands(ExternalBase):
 
42
 
 
43
    def test_ignore_patterns(self):
 
44
        self.runbzr('init')
 
45
        self.assertEquals(self.capture('unknowns'), '')
 
46
 
 
47
        self.build_tree_contents(
 
48
            [('foo.tmp', 'tmp files are ignored'),
 
49
             ('.bzrignore', '*.tmp'),
 
50
             ])
 
51
        self.run_bzr('add', '.bzrignore')
 
52
        self.assertEquals(self.capture('unknowns'), '')
 
53
 
 
54
        file('foo.c', 'wt').write('int main() {}')
 
55
        self.assertEquals(self.capture('unknowns'), 'foo.c\n')
 
56
 
 
57
        self.runbzr(['add', 'foo.c'])
 
58
        self.assertEquals(self.capture('unknowns'), '')
 
59
 
 
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')
 
66
 
 
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')
 
73
        
 
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)