~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository_reference/__init__.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from bzrlib import (
26
26
    errors,
27
27
    remote,
 
28
    urlutils,
28
29
    )
29
 
from bzrlib.bzrdir import BzrDir
 
30
from bzrlib.controldir import ControlDir
30
31
from bzrlib.tests import multiply_tests
31
32
from bzrlib.tests.per_repository import (
32
33
    all_repository_format_scenarios,
36
37
 
37
38
class TestCaseWithExternalReferenceRepository(TestCaseWithRepository):
38
39
 
39
 
    def make_referring(self, relpath, target_path):
 
40
    def make_referring(self, relpath, a_repository):
40
41
        """Get a new repository that refers to a_repository.
41
42
 
42
43
        :param relpath: The path to create the repository at.
43
44
        :param a_repository: A repository to refer to.
44
45
        """
45
46
        repo = self.make_repository(relpath)
46
 
        repo.add_fallback_repository(self.readonly_repository(target_path))
 
47
        repo.add_fallback_repository(self.readonly_repository(a_repository))
47
48
        return repo
48
49
 
49
 
    def readonly_repository(self, relpath):
50
 
        return BzrDir.open_from_transport(
 
50
    def readonly_repository(self, repo):
 
51
        relpath = urlutils.basename(repo.bzrdir.user_url.rstrip('/'))
 
52
        return ControlDir.open_from_transport(
51
53
            self.get_readonly_transport(relpath)).open_repository()
52
54
 
53
55
 
58
60
        # because developers use this api to setup the tree, branch and
59
61
        # repository for their tests: having it not give the right repository
60
62
        # type would invalidate the tests.
61
 
        self.make_branch_and_tree('repo')
62
 
        repo = self.make_referring('referring', 'repo')
 
63
        tree = self.make_branch_and_tree('repo')
 
64
        repo = self.make_referring('referring', tree.branch.repository)
63
65
        self.assertIsInstance(repo._format,
64
66
            self.repository_format.__class__)
65
67