153
153
self.runbzr('commit -m newstuff branch')
154
154
self.runbzr('commit -m newstuff branch', retcode=1)
157
156
def test_ignore_patterns(self):
158
157
from bzrlib.branch import Branch
160
b = Branch.initialize('.')
161
self.assertEquals(list(b.unknowns()), [])
158
Branch.initialize('.')
159
self.assertEquals(self.capture('unknowns'), '')
163
161
file('foo.tmp', 'wt').write('tmp files are ignored')
164
self.assertEquals(list(b.unknowns()), [])
165
162
self.assertEquals(self.capture('unknowns'), '')
167
164
file('foo.c', 'wt').write('int main() {}')
168
self.assertEquals(list(b.unknowns()), ['foo.c'])
169
165
self.assertEquals(self.capture('unknowns'), 'foo.c\n')
171
167
self.runbzr(['add', 'foo.c'])
174
170
# 'ignore' works when creating the .bzignore file
175
171
file('foo.blah', 'wt').write('blah')
176
self.assertEquals(list(b.unknowns()), ['foo.blah'])
172
self.assertEquals(self.capture('unknowns'), 'foo.blah\n')
177
173
self.runbzr('ignore *.blah')
178
self.assertEquals(list(b.unknowns()), [])
174
self.assertEquals(self.capture('unknowns'), '')
179
175
self.assertEquals(file('.bzrignore', 'rU').read(), '*.blah\n')
181
177
# 'ignore' works when then .bzrignore file already exists
182
178
file('garh', 'wt').write('garh')
183
self.assertEquals(list(b.unknowns()), ['garh'])
184
179
self.assertEquals(self.capture('unknowns'), 'garh\n')
185
180
self.runbzr('ignore garh')
186
self.assertEquals(list(b.unknowns()), [])
181
self.assertEquals(self.capture('unknowns'), '')
187
182
self.assertEquals(file('.bzrignore', 'rU').read(), '*.blah\ngarh\n')
189
184
def test_revert(self):
675
670
results = sorted(out.rstrip('\n').split('\n'))
676
671
self.assertEquals([''], results)
673
def test_add_in_unversioned(self):
674
"""Try to add a file in an unversioned directory.
676
"bzr add" should add the parent(s) as necessary.
678
from bzrlib.branch import Branch
679
Branch.initialize('.')
680
self.build_tree(['inertiatic/', 'inertiatic/esp'])
681
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
682
self.run_bzr('add', 'inertiatic/esp')
683
self.assertEquals(self.capture('unknowns'), '')
685
# Multiple unversioned parents
686
self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
687
self.assertEquals(self.capture('unknowns'), 'veil\n')
688
self.run_bzr('add', 'veil/cerpin/taxt')
689
self.assertEquals(self.capture('unknowns'), '')
691
# Check whacky paths work
692
self.build_tree(['cicatriz/', 'cicatriz/esp'])
693
self.assertEquals(self.capture('unknowns'), 'cicatriz\n')
694
self.run_bzr('add', 'inertiatic/../cicatriz/esp')
695
self.assertEquals(self.capture('unknowns'), '')
697
def test_add_in_versioned(self):
698
"""Try to add a file in a versioned directory.
700
"bzr add" should do this happily.
702
from bzrlib.branch import Branch
703
Branch.initialize('.')
704
self.build_tree(['inertiatic/', 'inertiatic/esp'])
705
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
706
self.run_bzr('add', '--no-recurse', 'inertiatic')
707
self.assertEquals(self.capture('unknowns'), 'inertiatic'+os.sep+'esp\n')
708
self.run_bzr('add', 'inertiatic/esp')
709
self.assertEquals(self.capture('unknowns'), '')
711
def test_subdir_add(self):
712
"""Add in subdirectory should add only things from there down"""
713
from bzrlib.branch import Branch
715
eq = self.assertEqual
719
b = Branch.initialize('.')
721
self.build_tree(['src/', 'README'])
723
eq(sorted(t.unknowns()),
726
self.run_bzr('add', 'src')
728
self.build_tree(['src/foo.c'])
733
self.assertEquals(self.capture('unknowns'), 'README\n')
734
eq(len(t.read_working_inventory()), 3)
738
self.assertEquals(self.capture('unknowns'), '')
739
self.run_bzr('check')
678
741
def test_unknown_command(self):
679
742
"""Handling of unknown command."""
680
743
out, err = self.run_bzr_captured(['fluffy-badger'],