/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_tree.py

  • Committer: John Arbash Meinel
  • Date: 2008-06-30 19:48:01 UTC
  • mto: (3697.7.4 1.7)
  • mto: This revision was merged to the branch mainline in revision 3599.
  • Revision ID: john@arbash-meinel.com-20080630194801-gdodhpossmf1n85a
Handle the case when a record is missing in base

Show diffs side-by-side

added added

removed removed

Lines of Context:
180
180
        self.assertStepOne(False, None, None, iterator)
181
181
        self.assertStepOne(False, None, None, iterator)
182
182
 
 
183
    def assertWalkerNext(self, exp_path, exp_file_id, master_is_None,
 
184
                         exp_other_paths, iterator):
 
185
        """Check what happens when we step the iterator.
 
186
 
 
187
        :param path: The path for this entry
 
188
        :param file_id: The file_id for this entry
 
189
        :param master_is_None: Is this node None for the master tree?
 
190
        :param exp_other_paths: A list of other_path values.
 
191
        :param iterator: The iterator to step
 
192
        """
 
193
        path, file_id, master_ie, other_values = iterator.next()
 
194
        self.assertEqual(exp_path, path)
 
195
        self.assertEqual(exp_file_id, file_id)
 
196
        if master_is_None:
 
197
            self.assertIs(None, master_ie)
 
198
        else:
 
199
            self.assertIsNot(None, master_ie)
 
200
        self.assertEqual(len(exp_other_paths), len(other_values))
 
201
        for exp_other_path, (other_path, other_ie) in \
 
202
                zip(exp_other_paths, other_values):
 
203
            self.assertEqual(exp_other_path, other_path)
 
204
            if exp_other_path is None:
 
205
                self.assertIs(None, other_ie)
 
206
            else:
 
207
                self.assertEqual(file_id, other_ie.file_id)
 
208
 
183
209
    def test_simple_stepping(self):
184
210
        tree = self.make_branch_and_tree('tree')
185
211
        self.build_tree(['tree/a', 'tree/b/', 'tree/b/c'])
192
218
        basis_tree.lock_read()
193
219
        self.addCleanup(basis_tree.unlock)
194
220
 
195
 
        walker = _mod_tree.MultiWalker(tree, [basis_tree])
196
 
        iterator = walker.iter_all()
197
 
        master_path, file_id, master_ie, other_values = iterator.next()
198
 
        root_id = tree.path2id('')
199
 
        self.assertEqual('', master_path)
200
 
        self.assertEqual(root_id, file_id)
201
 
        self.assertEqual(1, len(other_values))
202
 
        other_path, other_ie = other_values[0]
203
 
        self.assertEqual('', other_path)
204
 
        self.assertEqual(root_id, other_ie.file_id)
205
 
 
206
 
        master_path, file_id, master_ie, other_values = iterator.next()
207
 
        self.assertEqual(u'a', master_path)
208
 
        self.assertEqual('a-id', file_id)
209
 
        self.assertEqual(1, len(other_values))
210
 
        other_path, other_ie = other_values[0]
211
 
        self.assertEqual(u'a', other_path)
212
 
        self.assertEqual('a-id', other_ie.file_id)
213
 
 
214
 
        master_path, file_id, master_ie, other_values = iterator.next()
215
 
        self.assertEqual(u'b', master_path)
216
 
        self.assertEqual('b-id', file_id)
217
 
        self.assertEqual(1, len(other_values))
218
 
        other_path, other_ie = other_values[0]
219
 
        self.assertEqual(u'b', other_path)
220
 
        self.assertEqual('b-id', other_ie.file_id)
221
 
 
222
 
        master_path, file_id, master_ie, other_values = iterator.next()
223
 
        self.assertEqual(u'b/c', master_path)
224
 
        self.assertEqual('c-id', file_id)
225
 
        self.assertEqual(1, len(other_values))
226
 
        other_path, other_ie = other_values[0]
227
 
        self.assertEqual(u'b/c', other_path)
228
 
        self.assertEqual('c-id', other_ie.file_id)
229
 
 
 
221
        root_id = tree.path2id('')
 
222
 
 
223
        walker = _mod_tree.MultiWalker(tree, [basis_tree])
 
224
        iterator = walker.iter_all()
 
225
        self.assertWalkerNext(u'', root_id, False, [u''], iterator)
 
226
        self.assertWalkerNext(u'a', 'a-id', False, [u'a'], iterator)
 
227
        self.assertWalkerNext(u'b', 'b-id', False, [u'b'], iterator)
 
228
        self.assertWalkerNext(u'b/c', 'c-id', False, [u'b/c'], iterator)
 
229
        self.assertRaises(StopIteration, iterator.next)
 
230
 
 
231
    def test_master_has_extra(self):
 
232
        tree = self.make_branch_and_tree('tree')
 
233
        self.build_tree(['tree/a', 'tree/b/', 'tree/c', 'tree/d'])
 
234
        tree.add(['a', 'b', 'd'], ['a-id', 'b-id', 'd-id'])
 
235
 
 
236
        tree.commit('first', rev_id='first-rev-id')
 
237
        basis_tree = tree.basis_tree()
 
238
 
 
239
        tree.add(['c'], ['c-id'])
 
240
        tree.lock_read()
 
241
        self.addCleanup(tree.unlock)
 
242
        basis_tree.lock_read()
 
243
        self.addCleanup(basis_tree.unlock)
 
244
 
 
245
        root_id = tree.path2id('')
 
246
        walker = _mod_tree.MultiWalker(tree, [basis_tree])
 
247
        iterator = walker.iter_all()
 
248
        self.assertWalkerNext(u'', root_id, False, [u''], iterator)
 
249
        self.assertWalkerNext(u'a', 'a-id', False, [u'a'], iterator)
 
250
        self.assertWalkerNext(u'b', 'b-id', False, [u'b'], iterator)
 
251
        self.assertWalkerNext(u'c', 'c-id', False, [None], iterator)
 
252
        self.assertWalkerNext(u'd', 'd-id', False, [u'd'], iterator)
230
253
        self.assertRaises(StopIteration, iterator.next)