~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
        
112
112
        self.build_tree(['src/foo.c'])
113
113
        
 
114
        # add with no arguments in a subdirectory gets only files below that
 
115
        # subdirectory
114
116
        chdir('src')
115
117
        self.run_bzr('add')
116
 
        
117
118
        self.assertEquals(self.capture('unknowns'), 'README\n')
118
 
        eq(len(t.read_working_inventory()), 3)
 
119
        # reopen to see the new changes
 
120
        t = t.bzrdir.open_workingtree()
 
121
        versioned = [path for path, entry in t.iter_entries_by_dir()]
 
122
        self.assertEquals(versioned,
 
123
            ['', 'src', 'src/foo.c'])
119
124
                
 
125
        # add from the parent directory should pick up all file names
120
126
        chdir('..')
121
127
        self.run_bzr('add')
122
128
        self.assertEquals(self.capture('unknowns'), '')
143
149
                             'added b w/ file id from b\n'
144
150
                             'added b/c w/ file id from b/c\n',
145
151
                             out)
146
 
 
147
 
        new_tree.read_working_inventory()
 
152
        new_tree = new_tree.bzrdir.open_workingtree()
148
153
        self.assertEqual(base_tree.path2id('a'), new_tree.path2id('a'))
149
154
        self.assertEqual(base_tree.path2id('b'), new_tree.path2id('b'))
150
155
        self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('b/c'))
165
170
                             'added d w/ file id from b/d\n',
166
171
                             out)
167
172
 
168
 
        new_tree.read_working_inventory()
 
173
        new_tree = new_tree.bzrdir.open_workingtree()
169
174
        self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('c'))
170
175
        self.assertEqual(base_tree.path2id('b/d'), new_tree.path2id('d'))
171
176
 
177
182
        self.assertEquals('added spam\n', out)
178
183
        out = self.run_bzr_captured(['added'], retcode=0)[0]
179
184
        self.assertEquals('', out)
 
185
 
 
186
    def test_add_control_dir(self):
 
187
        """The control dir and its content should be refused."""
 
188
        self.make_branch_and_tree('.')
 
189
        err = self.run_bzr('add', '.bzr', retcode=3)[1]
 
190
        self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
 
191
        err = self.run_bzr('add', '.bzr/README', retcode=3)[1]
 
192
        self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
 
193
        self.build_tree(['.bzr/crescent'])
 
194
        err = self.run_bzr('add', '.bzr/crescent', retcode=3)[1]
 
195
        self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')