64
64
self.assertEquals(self.run_bzr('unknowns')[0], 'dir3\n')
66
66
def test_ignore_patterns(self):
68
self.assertEquals(self.run_bzr('unknowns')[0], '')
67
tree = self.make_branch_and_tree('.')
69
self.assertEquals(list(tree.unknowns()), [])
70
71
# is_ignored() will now create the user global ignore file
71
72
# if it doesn't exist, so make sure we ignore it in our tests
72
73
ignores._set_user_ignores(['*.tmp'])
74
75
self.build_tree_contents(
75
[('foo.tmp', '.tmp files are ignored by default'),
77
self.assertEquals(self.run_bzr('unknowns')[0], '')
79
file('foo.c', 'wt').write('int main() {}')
80
self.assertEquals(self.run_bzr('unknowns')[0], 'foo.c\n')
82
self.run_bzr('add foo.c')
83
self.assertEquals(self.run_bzr('unknowns')[0], '')
76
[('foo.tmp', '.tmp files are ignored by default')])
77
self.assertEquals(list(tree.unknowns()), [])
79
self.build_tree_contents([('foo.c', 'int main() {}')])
80
self.assertEquals(list(tree.unknowns()), ['foo.c'])
83
self.assertEquals(list(tree.unknowns()), [])
85
85
# 'ignore' works when creating the .bzrignore file
86
file('foo.blah', 'wt').write('blah')
87
self.assertEquals(self.run_bzr('unknowns')[0], 'foo.blah\n')
86
self.build_tree_contents([('foo.blah', 'blah')])
87
self.assertEquals(list(tree.unknowns()), ['foo.blah'])
88
88
self.run_bzr('ignore *.blah')
89
self.assertEquals(self.run_bzr('unknowns')[0], '')
89
self.assertEquals(list(tree.unknowns()), [])
90
90
self.check_file_contents('.bzrignore', '*.blah\n')
92
92
# 'ignore' works when then .bzrignore file already exists
93
file('garh', 'wt').write('garh')
94
self.assertEquals(self.run_bzr('unknowns')[0], 'garh\n')
93
self.build_tree_contents([('garh', 'garh')])
94
self.assertEquals(list(tree.unknowns()), ['garh'])
95
95
self.run_bzr('ignore garh')
96
self.assertEquals(self.run_bzr('unknowns')[0], '')
96
self.assertEquals(list(tree.unknowns()), [])
97
97
self.check_file_contents('.bzrignore', '*.blah\ngarh\n')
99
99
def test_ignore_multiple_arguments(self):
100
100
"""'ignore' works with multiple arguments"""
101
tree = self.make_branch_and_tree('.')
102
102
self.build_tree(['a','b','c','d'])
103
self.assertEquals(self.run_bzr('unknowns')[0], 'a\nb\nc\nd\n')
103
self.assertEquals(list(tree.unknowns()), ['a', 'b', 'c', 'd'])
104
104
self.run_bzr('ignore a b c')
105
self.assertEquals(self.run_bzr('unknowns')[0], 'd\n')
105
self.assertEquals(list(tree.unknowns()), ['d'])
106
106
self.check_file_contents('.bzrignore', 'a\nb\nc\n')
108
108
def test_ignore_no_arguments(self):
109
109
"""'ignore' with no arguments returns an error"""
110
self.make_branch_and_tree('.')
111
111
self.run_bzr_error(('bzr: ERROR: ignore requires at least one '
112
112
'NAME_PATTERN or --old-default-rules\n',),