~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/versioning.py

Move Branch.unknowns() to WorkingTree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
        
138
138
        self.check_branch()
139
139
 
140
 
    def test_add_in_unversioned(self):
141
 
        """Try to add a file in an unversioned directory.
142
 
 
143
 
        "bzr add" should add the parent(s) as necessary.
144
 
        """
145
 
        from bzrlib.branch import Branch
146
 
        eq = self.assertEqual
147
 
 
148
 
        b = Branch.initialize('.')
149
 
 
150
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
151
 
        eq(list(b.unknowns()), ['inertiatic'])
152
 
        self.run_bzr('add', 'inertiatic/esp')
153
 
        eq(list(b.unknowns()), [])
154
 
 
155
 
        # Multiple unversioned parents
156
 
        self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
157
 
        eq(list(b.unknowns()), ['veil'])
158
 
        self.run_bzr('add', 'veil/cerpin/taxt')
159
 
        eq(list(b.unknowns()), [])
160
 
 
161
 
        # Check whacky paths work
162
 
        self.build_tree(['cicatriz/', 'cicatriz/esp'])
163
 
        eq(list(b.unknowns()), ['cicatriz'])
164
 
        self.run_bzr('add', 'inertiatic/../cicatriz/esp')
165
 
        eq(list(b.unknowns()), [])
166
 
 
167
 
    def test_add_in_versioned(self):
168
 
        """Try to add a file in a versioned directory.
169
 
 
170
 
        "bzr add" should do this happily.
171
 
        """
172
 
        from bzrlib.branch import Branch
173
 
        eq = self.assertEqual
174
 
 
175
 
        b = Branch.initialize('.')
176
 
 
177
 
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
178
 
        eq(list(b.unknowns()), ['inertiatic'])
179
 
        self.run_bzr('add', '--no-recurse', 'inertiatic')
180
 
        eq(list(b.unknowns()), ['inertiatic'+os.sep+'esp'])
181
 
        self.run_bzr('add', 'inertiatic/esp')
182
 
        eq(list(b.unknowns()), [])
183
 
 
184
 
    def test_subdir_add(self):
185
 
        """Add in subdirectory should add only things from there down"""
186
 
        
187
 
        from bzrlib.branch import Branch
188
 
        
189
 
        eq = self.assertEqual
190
 
        ass = self.assert_
191
 
        chdir = os.chdir
192
 
        
193
 
        b = Branch.initialize('.')
194
 
        t = b.working_tree()
195
 
        self.build_tree(['src/', 'README'])
196
 
        
197
 
        eq(sorted(b.unknowns()),
198
 
           ['README', 'src'])
199
 
        
200
 
        self.run_bzr('add', 'src')
201
 
        
202
 
        self.build_tree(['src/foo.c'])
203
 
        
204
 
        chdir('src')
205
 
        self.run_bzr('add')
206
 
        
207
 
        eq(sorted(b.unknowns()), 
208
 
           ['README'])
209
 
        eq(len(t.read_working_inventory()), 3)
210
 
                
211
 
        chdir('..')
212
 
        self.run_bzr('add')
213
 
        eq(list(b.unknowns()), [])
214
 
 
215
 
        self.check_branch()
216
 
 
217
140
    def check_branch(self):
218
141
        """After all the above changes, run the check and upgrade commands.
219
142