~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/intertree_implementations/test_compare.py

Crufty but existing _iter_changes implementation for WorkingTreeFormat4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib import errors
22
22
from bzrlib.tests.intertree_implementations import TestCaseWithTwoTrees
23
23
 
 
24
# TODO: test diff unversioned dir that exists
 
25
# TODO: test the include_root option.
 
26
# TODO: test that renaming a directory x->y does not emit a rename for the
 
27
#       child x/a->y/a.
 
28
# TODO: test that renaming a directory x-> does not emit a rename for the child
 
29
#        x/a -> y/a when a supplied_files argument gives either 'x/' or 'y/a'
 
30
#        -> that is, when the renamed parent is not processed by the function.
 
31
# TODO: include unknowns in the diff output.
 
32
# TODO: include dangling in the diff output.
 
33
# TODO: test items are only emitted once when a specific_files list names a dir
 
34
#       whose parent is now a child.
 
35
# TODO: test require_versioned
24
36
 
25
37
class TestCompare(TestCaseWithTwoTrees):
26
38
 
283
295
        tree1.lock_read()
284
296
        tree2.lock_read()
285
297
        try:
286
 
            return list(self.intertree_class(tree1, tree2)
 
298
            # sort order of output is not strictly defined
 
299
            return sorted(self.intertree_class(tree1, tree2)
287
300
                ._iter_changes(**extra_args))
288
301
        finally:
289
302
            tree1.unlock()
319
332
        tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
320
333
        tree1.lock_read()
321
334
        tree2.lock_read()
322
 
        expected_results = [
 
335
        expected_results = sorted([
323
336
            self.added(tree2, 'root-id'),
324
337
            self.added(tree2, 'a-id'),
325
338
            self.added(tree2, 'b-id'),
326
339
            self.added(tree2, 'c-id'),
327
 
            self.deleted(tree1, 'empty-root-id')]
 
340
            self.deleted(tree1, 'empty-root-id')])
328
341
        tree1.unlock()
329
342
        tree2.unlock()
330
343
        self.assertEqual(expected_results, self.do_iter_changes(tree1, tree2))
339
352
        tree2.lock_read()
340
353
        self.assertEqual(
341
354
            [self.added(tree2, 'a-id')],
342
 
            self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id']))
 
355
            self.do_iter_changes(tree1, tree2, specific_files=['a']))
343
356
        tree1.unlock()
344
357
        tree2.unlock()
345
358
 
353
366
        tree2.lock_read()
354
367
        self.assertEqual(
355
368
            [self.deleted(tree1, 'a-id')],
356
 
            self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id']))
 
369
            self.do_iter_changes(tree1, tree2, specific_files=['a']))
357
370
        tree1.unlock()
358
371
        tree2.unlock()
359
372
 
369
382
        tree1.unlock()
370
383
        tree2.unlock()
371
384
        self.assertEqual(expected_result,
372
 
            self.do_iter_changes(tree1, tree2, specific_file_ids=['a-id', 'c-id']))
 
385
            self.do_iter_changes(tree1, tree2, specific_files=['a', 'b/c']))
373
386
 
374
387
    def test_abc_content_to_empty(self):
375
388
        tree1 = self.make_branch_and_tree('1')
386
399
                    (entry.parent_id, None),
387
400
                    (entry.name, None), (entry.kind, None),
388
401
                    (entry.executable, None))
389
 
        expected_results = [self.added(tree2, 'empty-root-id'),
 
402
        expected_results = sorted([self.added(tree2, 'empty-root-id'),
390
403
                          deleted('root-id'), deleted('a-id'),
391
 
                          deleted('b-id'), deleted('c-id')]
 
404
                          deleted('b-id'), deleted('c-id')])
392
405
        tree1.unlock()
393
406
        tree2.unlock()
394
407
        self.assertEqual(
475
488
            return (file_id, tree1.id2path(file_id), False, (True, True),
476
489
                   (parent, parent), (name, name), (kind, kind),
477
490
                   (executable, executable))
478
 
        self.assertEqual([unchanged(root_id), unchanged('b-id'),
 
491
        self.assertEqual(sorted([unchanged(root_id), unchanged('b-id'),
479
492
                          ('a-id', 'd', True, (True, True),
480
493
                          (root_id, root_id), ('a', 'd'), ('file', 'file'),
481
 
                          (False, False)), unchanged('c-id')],
 
494
                          (False, False)), unchanged('c-id')]),
482
495
                         self.do_iter_changes(tree1, tree2, include_unchanged=True))