~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

Move Branch.unknowns() to WorkingTree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
        self.runbzr('commit -m newstuff branch')
154
154
        self.runbzr('commit -m newstuff branch', retcode=1)
155
155
 
156
 
 
157
156
    def test_ignore_patterns(self):
158
157
        from bzrlib.branch import Branch
159
 
        
160
 
        b = Branch.initialize('.')
161
 
        self.assertEquals(list(b.unknowns()), [])
 
158
        Branch.initialize('.')
 
159
        self.assertEquals(self.capture('unknowns'), '')
162
160
 
163
161
        file('foo.tmp', 'wt').write('tmp files are ignored')
164
 
        self.assertEquals(list(b.unknowns()), [])
165
162
        self.assertEquals(self.capture('unknowns'), '')
166
163
 
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')
170
166
 
171
167
        self.runbzr(['add', 'foo.c'])
173
169
 
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')
180
176
 
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')
188
183
 
189
184
    def test_revert(self):
675
670
        results = sorted(out.rstrip('\n').split('\n'))
676
671
        self.assertEquals([''], results)
677
672
 
 
673
    def test_add_in_unversioned(self):
 
674
        """Try to add a file in an unversioned directory.
 
675
 
 
676
        "bzr add" should add the parent(s) as necessary.
 
677
        """
 
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'), '')
 
684
 
 
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'), '')
 
690
 
 
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'), '')
 
696
 
 
697
    def test_add_in_versioned(self):
 
698
        """Try to add a file in a versioned directory.
 
699
 
 
700
        "bzr add" should do this happily.
 
701
        """
 
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'), '')
 
710
 
 
711
    def test_subdir_add(self):
 
712
        """Add in subdirectory should add only things from there down"""
 
713
        from bzrlib.branch import Branch
 
714
        
 
715
        eq = self.assertEqual
 
716
        ass = self.assert_
 
717
        chdir = os.chdir
 
718
        
 
719
        b = Branch.initialize('.')
 
720
        t = b.working_tree()
 
721
        self.build_tree(['src/', 'README'])
 
722
        
 
723
        eq(sorted(t.unknowns()),
 
724
           ['README', 'src'])
 
725
        
 
726
        self.run_bzr('add', 'src')
 
727
        
 
728
        self.build_tree(['src/foo.c'])
 
729
        
 
730
        chdir('src')
 
731
        self.run_bzr('add')
 
732
        
 
733
        self.assertEquals(self.capture('unknowns'), 'README\n')
 
734
        eq(len(t.read_working_inventory()), 3)
 
735
                
 
736
        chdir('..')
 
737
        self.run_bzr('add')
 
738
        self.assertEquals(self.capture('unknowns'), '')
 
739
        self.run_bzr('check')
 
740
 
678
741
    def test_unknown_command(self):
679
742
        """Handling of unknown command."""
680
743
        out, err = self.run_bzr_captured(['fluffy-badger'],