Exemple #1
0
    def test_push_only_pushes_history(self):
        # Knit branches should only push the history for the current revision.
        format = bzrdir.BzrDirMetaFormat1()
        format.repository_format = knitrepo.RepositoryFormatKnit1()
        shared_repo = self.make_repository('repo', format=format, shared=True)
        shared_repo.set_make_working_trees(True)

        def make_shared_tree(path):
            shared_repo.controldir.root_transport.mkdir(path)
            controldir.ControlDir.create_branch_convenience('repo/' + path)
            return workingtree.WorkingTree.open('repo/' + path)

        tree_a = make_shared_tree('a')
        self.build_tree(['repo/a/file'])
        tree_a.add('file')
        tree_a.commit('commit a-1', rev_id=b'a-1')
        f = open('repo/a/file', 'ab')
        f.write(b'more stuff\n')
        f.close()
        tree_a.commit('commit a-2', rev_id=b'a-2')

        tree_b = make_shared_tree('b')
        self.build_tree(['repo/b/file'])
        tree_b.add('file')
        tree_b.commit('commit b-1', rev_id=b'b-1')

        self.assertTrue(shared_repo.has_revision(b'a-1'))
        self.assertTrue(shared_repo.has_revision(b'a-2'))
        self.assertTrue(shared_repo.has_revision(b'b-1'))

        # Now that we have a repository with shared files, make sure
        # that things aren't copied out by a 'push'
        self.run_bzr('push ../../push-b', working_dir='repo/b')
        pushed_tree = workingtree.WorkingTree.open('push-b')
        pushed_repo = pushed_tree.branch.repository
        self.assertFalse(pushed_repo.has_revision(b'a-1'))
        self.assertFalse(pushed_repo.has_revision(b'a-2'))
        self.assertTrue(pushed_repo.has_revision(b'b-1'))
Exemple #2
0
def default_test_list():
    """Generate the default list of interrepo permutations to test."""
    from breezy.bzr import (
        groupcompress_repo,
        knitrepo,
        knitpack_repo,
    )
    result = []

    def add_combo(interrepo_cls,
                  from_format,
                  to_format,
                  extra_setup=None,
                  label=None):
        if label is None:
            label = interrepo_cls.__name__
        result.append((label, from_format, to_format, extra_setup))

    # test the default InterRepository between format 6 and the current
    # default format.
    # XXX: robertc 20060220 reinstate this when there are two supported
    # formats which do not have an optimal code path between them.
    # result.append((InterRepository,
    #               RepositoryFormat6(),
    #               RepositoryFormatKnit1()))
    for optimiser_class in InterRepository.iter_optimisers():
        format_to_test = optimiser_class._get_repo_format_to_test()
        if format_to_test is not None:
            add_combo(optimiser_class, format_to_test, format_to_test)
    # if there are specific combinations we want to use, we can add them
    # here. We want to test rich root upgrading.
    # XXX: although we attach InterRepository class names to these scenarios,
    # there's nothing asserting that these labels correspond to what is
    # actually used.

    def force_known_graph(testcase):
        from breezy.bzr.fetch import Inter1and2Helper
        testcase.overrideAttr(Inter1and2Helper, 'known_graph_threshold', -1)

    # Gather extra scenarios from the repository implementations,
    # as InterRepositories can be used by Repository implementations
    # they aren't aware of.
    for module_name in format_registry._get_all_modules():
        module = pyutils.get_named_object(module_name)
        try:
            get_extra_interrepo_test_combinations = getattr(
                module, "get_extra_interrepo_test_combinations")
        except AttributeError:
            continue
        for (interrepo_cls, from_format,
             to_format) in (get_extra_interrepo_test_combinations()):
            add_combo(interrepo_cls, from_format, to_format)
    add_combo(InterRepository, knitrepo.RepositoryFormatKnit1(),
              knitrepo.RepositoryFormatKnit3())
    add_combo(knitrepo.InterKnitRepo, knitrepo.RepositoryFormatKnit1(),
              knitpack_repo.RepositoryFormatKnitPack1())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitrepo.RepositoryFormatKnit1())
    add_combo(knitrepo.InterKnitRepo, knitrepo.RepositoryFormatKnit3(),
              knitpack_repo.RepositoryFormatKnitPack3())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack3(),
              knitrepo.RepositoryFormatKnit3())
    add_combo(knitrepo.InterKnitRepo,
              knitpack_repo.RepositoryFormatKnitPack3(),
              knitpack_repo.RepositoryFormatKnitPack4())
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack1(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot(),
              force_known_graph,
              label='InterDifferingSerializer+get_known_graph_ancestry')
    add_combo(InterDifferingSerializer,
              knitpack_repo.RepositoryFormatKnitPack6RichRoot(),
              groupcompress_repo.RepositoryFormat2a())
    add_combo(InterDifferingSerializer,
              groupcompress_repo.RepositoryFormat2a(),
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
    return result