~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

merge trunk

Show diffs side-by-side

added added

removed removed

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