コード例 #1
0
ファイル: features.py プロジェクト: zeta1999/breezy
 def _ensure(self):
     if self._feature is None:
         from breezy import pyutils
         depr_msg = self._dep_version % ('%s.%s'
                                         % (self._module, self._name))
         use_msg = ' Use %s.%s instead.' % (self._replacement_module,
                                            self._replacement_name)
         symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning,
                                stacklevel=5)
         # Import the new feature and use it as a replacement for the
         # deprecated one.
         self._feature = pyutils.get_named_object(
             self._replacement_module, self._replacement_name)
コード例 #2
0
ファイル: test_pyutils.py プロジェクト: zeta1999/breezy
 def test_package_attr(self):
     # breezy.tests is a package, not simply a module
     self.assertIs(
         tests.TestCase, get_named_object('breezy.tests', 'TestCase'))
コード例 #3
0
ファイル: test_pyutils.py プロジェクト: zeta1999/breezy
 def test_package(self):
     # breezy.tests is a package, not simply a module
     self.assertIs(tests, get_named_object('breezy.tests'))
コード例 #4
0
ファイル: test_pyutils.py プロジェクト: zeta1999/breezy
 def test_dotted_attr(self):
     self.assertIs(
         branch.Branch.hooks,
         get_named_object('breezy.branch', 'Branch.hooks'))
コード例 #5
0
ファイル: test_pyutils.py プロジェクト: zeta1999/breezy
 def test_module_attr(self):
     self.assertIs(
         branch.Branch, get_named_object('breezy.branch', 'Branch'))
コード例 #6
0
ファイル: test_pyutils.py プロジェクト: zeta1999/breezy
 def test_dotted_module(self):
     self.assertIs(branch, get_named_object('breezy.branch'))
コード例 #7
0
ファイル: test_pyutils.py プロジェクト: zeta1999/breezy
 def test_module_only(self):
     import sys
     self.assertIs(sys, get_named_object('sys'))
コード例 #8
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