~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:56:05 UTC
  • mfrom: (6615.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201195605-o7rl92wf6uyum3fk
(vila) Open trunk again as 2.8b1 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011, 2016 Canonical Ltd
2
2
# Authors: Robert Collins <robert.collins@canonical.com>
3
3
# -*- coding: utf-8 -*-
4
4
#
26
26
"""
27
27
 
28
28
 
29
 
from bzrlib import transport
 
29
from bzrlib import (
 
30
    pyutils,
 
31
    transport,
 
32
    )
30
33
from bzrlib.errors import (
31
34
    FileExists,
32
35
    UninitializableFormat,
33
36
    )
34
37
 
35
38
from bzrlib.repository import (
 
39
    format_registry,
36
40
    InterRepository,
37
41
    )
38
42
from bzrlib.tests import (
39
 
                          default_transport,
40
 
                          multiply_tests,
41
 
                          )
 
43
    TestSkipped,
 
44
    default_transport,
 
45
    multiply_tests,
 
46
    )
42
47
from bzrlib.tests.per_controldir.test_controldir import TestCaseWithControlDir
 
48
from bzrlib.vf_repository import (
 
49
    InterDifferingSerializer,
 
50
    )
43
51
 
44
52
 
45
53
def make_scenarios(transport_server, transport_readonly_server, formats):
49
57
        (label, repository_format, repository_format_to).
50
58
    """
51
59
    result = []
52
 
    for label, repository_format, repository_format_to in formats:
 
60
    for label, repository_format, repository_format_to, extra_setup in formats:
53
61
        id = '%s,%s,%s' % (label, repository_format.__class__.__name__,
54
62
                           repository_format_to.__class__.__name__)
55
63
        scenario = (id,
57
65
             "transport_readonly_server": transport_readonly_server,
58
66
             "repository_format": repository_format,
59
67
             "repository_format_to": repository_format_to,
 
68
             "extra_setup": extra_setup,
60
69
             })
61
70
        result.append(scenario)
62
71
    return result
67
76
    from bzrlib.repofmt import (
68
77
        groupcompress_repo,
69
78
        knitrepo,
70
 
        pack_repo,
71
 
        weaverepo,
 
79
        knitpack_repo,
72
80
        )
73
81
    result = []
74
 
    def add_combo(label, from_format, to_format):
75
 
        result.append((label, from_format, to_format))
 
82
    def add_combo(interrepo_cls, from_format, to_format, extra_setup=None,
 
83
                  label=None):
 
84
        if label is None:
 
85
            label = interrepo_cls.__name__
 
86
        result.append((label, from_format, to_format, extra_setup))
76
87
    # test the default InterRepository between format 6 and the current
77
88
    # default format.
78
89
    # XXX: robertc 20060220 reinstate this when there are two supported
83
94
    for optimiser_class in InterRepository._optimisers:
84
95
        format_to_test = optimiser_class._get_repo_format_to_test()
85
96
        if format_to_test is not None:
86
 
            add_combo(optimiser_class.__name__, format_to_test, format_to_test)
 
97
            add_combo(optimiser_class, format_to_test, format_to_test)
87
98
    # if there are specific combinations we want to use, we can add them
88
99
    # here. We want to test rich root upgrading.
89
100
    # XXX: although we attach InterRepository class names to these scenarios,
90
101
    # there's nothing asserting that these labels correspond to what is
91
102
    # actually used.
92
 
    add_combo('InterRepository',
93
 
              weaverepo.RepositoryFormat5(),
94
 
              knitrepo.RepositoryFormatKnit3())
95
 
    add_combo('InterRepository',
96
 
              knitrepo.RepositoryFormatKnit1(),
97
 
              knitrepo.RepositoryFormatKnit3())
98
 
    add_combo('InterKnitRepo',
99
 
              knitrepo.RepositoryFormatKnit1(),
100
 
              pack_repo.RepositoryFormatKnitPack1())
101
 
    add_combo('InterKnitRepo',
102
 
              pack_repo.RepositoryFormatKnitPack1(),
 
103
    def force_known_graph(testcase):
 
104
        from bzrlib.fetch import Inter1and2Helper
 
105
        testcase.overrideAttr(Inter1and2Helper, 'known_graph_threshold', -1)
 
106
    # Gather extra scenarios from the repository implementations,
 
107
    # as InterRepositories can be used by Repository implementations
 
108
    # they aren't aware of.
 
109
    for module_name in format_registry._get_all_modules():
 
110
        module = pyutils.get_named_object(module_name)
 
111
        try:
 
112
            get_extra_interrepo_test_combinations = getattr(
 
113
                module,
 
114
                "get_extra_interrepo_test_combinations")
 
115
        except AttributeError:
 
116
            continue
 
117
        for (interrepo_cls, from_format, to_format) in (
 
118
            get_extra_interrepo_test_combinations()):
 
119
            add_combo(interrepo_cls, from_format, to_format)
 
120
    add_combo(InterRepository,
 
121
              knitrepo.RepositoryFormatKnit1(),
 
122
              knitrepo.RepositoryFormatKnit3())
 
123
    add_combo(knitrepo.InterKnitRepo,
 
124
              knitrepo.RepositoryFormatKnit1(),
 
125
              knitpack_repo.RepositoryFormatKnitPack1())
 
126
    add_combo(knitrepo.InterKnitRepo,
 
127
              knitpack_repo.RepositoryFormatKnitPack1(),
103
128
              knitrepo.RepositoryFormatKnit1())
104
 
    add_combo('InterKnitRepo',
 
129
    add_combo(knitrepo.InterKnitRepo,
105
130
              knitrepo.RepositoryFormatKnit3(),
106
 
              pack_repo.RepositoryFormatKnitPack3())
107
 
    add_combo('InterKnitRepo',
108
 
              pack_repo.RepositoryFormatKnitPack3(),
 
131
              knitpack_repo.RepositoryFormatKnitPack3())
 
132
    add_combo(knitrepo.InterKnitRepo,
 
133
              knitpack_repo.RepositoryFormatKnitPack3(),
109
134
              knitrepo.RepositoryFormatKnit3())
110
 
    add_combo('InterKnitRepo',
111
 
              pack_repo.RepositoryFormatKnitPack3(),
112
 
              pack_repo.RepositoryFormatKnitPack4())
113
 
    add_combo('InterDifferingSerializer',
114
 
              pack_repo.RepositoryFormatKnitPack1(),
115
 
              pack_repo.RepositoryFormatKnitPack6RichRoot())
116
 
    add_combo('InterDifferingSerializer',
117
 
              pack_repo.RepositoryFormatKnitPack6RichRoot(),
 
135
    add_combo(knitrepo.InterKnitRepo,
 
136
              knitpack_repo.RepositoryFormatKnitPack3(),
 
137
              knitpack_repo.RepositoryFormatKnitPack4())
 
138
    add_combo(InterDifferingSerializer,
 
139
              knitpack_repo.RepositoryFormatKnitPack1(),
 
140
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
 
141
    add_combo(InterDifferingSerializer,
 
142
              knitpack_repo.RepositoryFormatKnitPack1(),
 
143
              knitpack_repo.RepositoryFormatKnitPack6RichRoot(),
 
144
              force_known_graph,
 
145
              label='InterDifferingSerializer+get_known_graph_ancestry')
 
146
    add_combo(InterDifferingSerializer,
 
147
              knitpack_repo.RepositoryFormatKnitPack6RichRoot(),
118
148
              groupcompress_repo.RepositoryFormat2a())
119
 
    add_combo('InterDifferingSerializer',
 
149
    add_combo(InterDifferingSerializer,
120
150
              groupcompress_repo.RepositoryFormat2a(),
121
 
              pack_repo.RepositoryFormatKnitPack6RichRoot())
122
 
    add_combo('InterRepository',
123
 
              groupcompress_repo.RepositoryFormatCHK2(),
124
 
              groupcompress_repo.RepositoryFormat2a())
125
 
    add_combo('InterDifferingSerializer',
126
 
              groupcompress_repo.RepositoryFormatCHK1(),
127
 
              groupcompress_repo.RepositoryFormat2a())
 
151
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
128
152
    return result
129
153
 
130
154
 
132
156
 
133
157
    def setUp(self):
134
158
        super(TestCaseWithInterRepository, self).setUp()
 
159
        if self.extra_setup:
 
160
            self.extra_setup(self)
 
161
 
 
162
    def get_default_format(self):
 
163
        self.assertEqual(
 
164
            self.repository_format._matchingbzrdir.repository_format,
 
165
            self.repository_format)
 
166
        return self.repository_format._matchingbzrdir
135
167
 
136
168
    def make_branch(self, relpath, format=None):
137
169
        repo = self.make_repository(relpath, format=format)