~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-08-14 07:41:17 UTC
  • mfrom: (3619.4.4 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080814074117-x0zvzzv7y6mok8pz
(robertc) Improve the testing of InterTree.iter_changes and fix bugs
        found as a result (Robert Collins, Aaron Bentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from bzrlib import errors, tests, workingtree_4
23
23
from bzrlib.osutils import file_kind, has_symlinks
 
24
from bzrlib.tests import TestNotApplicable
24
25
from bzrlib.tests.intertree_implementations import TestCaseWithTwoTrees
25
26
 
26
27
# TODO: test the include_root option.
695
696
            ])
696
697
        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
697
698
 
 
699
    def test_only_in_source_and_missing(self):
 
700
        tree1 = self.make_branch_and_tree('tree1')
 
701
        tree2 = self.make_to_branch_and_tree('tree2')
 
702
        tree2.set_root_id(tree1.get_root_id())
 
703
        self.build_tree(['tree1/file'])
 
704
        tree1.add(['file'], ['file-id'])
 
705
        os.unlink('tree1/file')
 
706
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
707
        root_id = tree1.path2id('')
 
708
        if not tree1.path2id('file'):
 
709
            # The locked test trees conversion could not preserve the missing
 
710
            # file status. This is normal (e.g. InterDirstateTree falls back
 
711
            # to InterTree if the basis is not a DirstateRevisionTree, and
 
712
            # revision trees cannot have missing files. 
 
713
            raise TestNotApplicable()
 
714
        expected = [('file-id', ('file', None), False, (True, False),
 
715
            (root_id, None), ('file', None), (None, None), (False, None))]
 
716
        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
 
717
 
 
718
    def test_only_in_target_and_missing(self):
 
719
        tree1 = self.make_branch_and_tree('tree1')
 
720
        tree2 = self.make_to_branch_and_tree('tree2')
 
721
        tree2.set_root_id(tree1.get_root_id())
 
722
        self.build_tree(['tree2/file'])
 
723
        tree2.add(['file'], ['file-id'])
 
724
        os.unlink('tree2/file')
 
725
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
726
        root_id = tree1.path2id('')
 
727
        expected = [('file-id', (None, 'file'), False, (False, True),
 
728
            (None, root_id), (None, 'file'), (None, None), (None, False))]
 
729
        self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
 
730
 
698
731
    def test_unchanged_with_renames_and_modifications(self):
699
732
        """want_unchanged should generate a list of unchanged entries."""
700
733
        tree1 = self.make_branch_and_tree('1')