Example #1
0
 def test_compare_calls_InterTree_compare(self):
     """This test tests the way Tree.compare() uses InterTree."""
     old_optimisers = InterTree._optimisers
     try:
         InterTree._optimisers = []
         RecordingOptimiser.calls = []
         InterTree.register_optimiser(RecordingOptimiser)
         tree = self.make_branch_and_tree('1')
         tree2 = self.make_branch_and_tree('2')
         # do a series of calls:
         # trivial usage
         tree.changes_from(tree2)
         # pass in all optional arguments by position
         tree.changes_from(tree2, 'unchanged', 'specific', 'extra',
                           'require', True)
         # pass in all optional arguments by keyword
         tree.changes_from(
             tree2,
             specific_files='specific',
             want_unchanged='unchanged',
             extra_trees='extra',
             require_versioned='require',
             include_root=True,
             want_unversioned=True,
         )
     finally:
         InterTree._optimisers = old_optimisers
     self.assertEqual([
         ('compare', tree2, tree, False, None, None, False, False, False),
         ('compare', tree2, tree, 'unchanged', 'specific', 'extra',
          'require', True, False),
         ('compare', tree2, tree, 'unchanged', 'specific', 'extra',
          'require', True, True),
     ], RecordingOptimiser.calls)
Example #2
0
 def test_working_tree_working_tree(self):
     # we should have an InterTree available for WorkingTree to
     # WorkingTree.
     tree = self.make_branch_and_tree('1')
     tree2 = self.make_branch_and_tree('2')
     optimiser = InterTree.get(tree, tree2)
     self.assertIsInstance(optimiser, InterTree)
     optimiser = InterTree.get(tree2, tree)
     self.assertIsInstance(optimiser, InterTree)
Example #3
0
 def test_working_tree_revision_tree(self):
     # we should have an InterTree available for WorkingTree to
     # RevisionTree.
     tree = self.make_branch_and_tree('.')
     rev_id = tree.commit('first post')
     rev_tree = tree.branch.repository.revision_tree(rev_id)
     optimiser = InterTree.get(rev_tree, tree)
     self.assertIsInstance(optimiser, InterTree)
     optimiser = InterTree.get(tree, rev_tree)
     self.assertIsInstance(optimiser, InterTree)
Example #4
0
 def test_revision_tree_revision_tree(self):
     # we should have an InterTree registered for RevisionTree to
     # RevisionTree.
     tree = self.make_branch_and_tree('.')
     rev_id = tree.commit('first post')
     rev_id2 = tree.commit('second post', allow_pointless=True)
     rev_tree = tree.branch.repository.revision_tree(rev_id)
     rev_tree2 = tree.branch.repository.revision_tree(rev_id2)
     optimiser = InterTree.get(rev_tree, rev_tree2)
     self.assertIsInstance(optimiser, InterTree)
     optimiser = InterTree.get(rev_tree2, rev_tree)
     self.assertIsInstance(optimiser, InterTree)
Example #5
0
def load_tests(loader, standard_tests, pattern):
    default_tree_format = WorkingTreeFormat3()
    submod_tests = loader.loadTestsFromModuleNames([
        'breezy.tests.per_intertree.test_compare',
        'breezy.tests.per_intertree.test_file_content_matches',
        'breezy.tests.per_intertree.test_find_path',
    ])
    test_intertree_permutations = [
        # test InterTree with two default-format working trees.
        (inventorytree.InterInventoryTree.__name__,
         inventorytree.InterInventoryTree, default_tree_format,
         default_tree_format, return_provided_trees)
    ]
    for optimiser in InterTree.iter_optimisers():
        if optimiser is inventorytree.InterCHKRevisionTree:
            # XXX: we shouldn't use an Intertree object to detect inventories
            # -- vila 20090311
            chk_tree_format = WorkingTreeFormat4()
            chk_tree_format._get_matchingcontroldir = \
                lambda: breezy.controldir.format_registry.make_controldir('2a')
            test_intertree_permutations.append(
                (inventorytree.InterInventoryTree.__name__ + "(CHKInventory)",
                 inventorytree.InterInventoryTree, chk_tree_format,
                 chk_tree_format, mutable_trees_to_revision_trees))
        elif optimiser is breezy.bzr.workingtree_4.InterDirStateTree:
            # Its a little ugly to be conditional here, but less so than having
            # the optimiser listed twice.
            # Add once, compiled version
            test_intertree_permutations.append(
                (optimiser.__name__ + "(C)", optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser.make_source_parent_tree_compiled_dirstate))
            # python version
            test_intertree_permutations.append(
                (optimiser.__name__ + "(PY)", optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser.make_source_parent_tree_python_dirstate))
        elif (optimiser._matching_from_tree_format is not None
              and optimiser._matching_to_tree_format is not None):
            test_intertree_permutations.append(
                (optimiser.__name__, optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser._test_mutable_trees_to_test_trees))
    # PreviewTree does not have an InterTree optimiser class.
    test_intertree_permutations.append(
        (inventorytree.InterInventoryTree.__name__ + "(PreviewTree)",
         inventorytree.InterInventoryTree, default_tree_format,
         default_tree_format, mutable_trees_to_preview_trees))
    scenarios = make_scenarios(
        default_transport,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        test_intertree_permutations)
    # add the tests for the sub modules to the standard tests.
    return multiply_tests(submod_tests, scenarios, standard_tests)