~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
"""
27
27
 
28
28
 
29
 
from bzrlib import (
30
 
    pyutils,
31
 
    transport,
32
 
    )
 
29
from bzrlib import transport
33
30
from bzrlib.errors import (
34
31
    FileExists,
35
32
    UninitializableFormat,
36
33
    )
37
34
 
38
35
from bzrlib.repository import (
39
 
    format_registry,
40
36
    InterRepository,
41
37
    )
42
38
from bzrlib.tests import (
43
 
    TestSkipped,
44
 
    default_transport,
45
 
    multiply_tests,
46
 
    )
 
39
                          default_transport,
 
40
                          multiply_tests,
 
41
                          )
47
42
from bzrlib.tests.per_controldir.test_controldir import TestCaseWithControlDir
48
 
from bzrlib.vf_repository import (
49
 
    InterDifferingSerializer,
50
 
    )
51
43
 
52
44
 
53
45
def make_scenarios(transport_server, transport_readonly_server, formats):
57
49
        (label, repository_format, repository_format_to).
58
50
    """
59
51
    result = []
60
 
    for label, repository_format, repository_format_to, extra_setup in formats:
 
52
    for label, repository_format, repository_format_to in formats:
61
53
        id = '%s,%s,%s' % (label, repository_format.__class__.__name__,
62
54
                           repository_format_to.__class__.__name__)
63
55
        scenario = (id,
65
57
             "transport_readonly_server": transport_readonly_server,
66
58
             "repository_format": repository_format,
67
59
             "repository_format_to": repository_format_to,
68
 
             "extra_setup": extra_setup,
69
60
             })
70
61
        result.append(scenario)
71
62
    return result
76
67
    from bzrlib.repofmt import (
77
68
        groupcompress_repo,
78
69
        knitrepo,
79
 
        knitpack_repo,
 
70
        pack_repo,
 
71
        weaverepo,
80
72
        )
81
73
    result = []
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))
 
74
    def add_combo(label, from_format, to_format):
 
75
        result.append((label, from_format, to_format))
87
76
    # test the default InterRepository between format 6 and the current
88
77
    # default format.
89
78
    # XXX: robertc 20060220 reinstate this when there are two supported
94
83
    for optimiser_class in InterRepository._optimisers:
95
84
        format_to_test = optimiser_class._get_repo_format_to_test()
96
85
        if format_to_test is not None:
97
 
            add_combo(optimiser_class, format_to_test, format_to_test)
 
86
            add_combo(optimiser_class.__name__, format_to_test, format_to_test)
98
87
    # if there are specific combinations we want to use, we can add them
99
88
    # here. We want to test rich root upgrading.
100
89
    # XXX: although we attach InterRepository class names to these scenarios,
101
90
    # there's nothing asserting that these labels correspond to what is
102
91
    # actually used.
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(),
 
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(),
128
103
              knitrepo.RepositoryFormatKnit1())
129
 
    add_combo(knitrepo.InterKnitRepo,
 
104
    add_combo('InterKnitRepo',
130
105
              knitrepo.RepositoryFormatKnit3(),
131
 
              knitpack_repo.RepositoryFormatKnitPack3())
132
 
    add_combo(knitrepo.InterKnitRepo,
133
 
              knitpack_repo.RepositoryFormatKnitPack3(),
 
106
              pack_repo.RepositoryFormatKnitPack3())
 
107
    add_combo('InterKnitRepo',
 
108
              pack_repo.RepositoryFormatKnitPack3(),
134
109
              knitrepo.RepositoryFormatKnit3())
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(),
 
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(),
148
118
              groupcompress_repo.RepositoryFormat2a())
149
 
    add_combo(InterDifferingSerializer,
 
119
    add_combo('InterDifferingSerializer',
150
120
              groupcompress_repo.RepositoryFormat2a(),
151
 
              knitpack_repo.RepositoryFormatKnitPack6RichRoot())
 
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())
152
128
    return result
153
129
 
154
130
 
156
132
 
157
133
    def setUp(self):
158
134
        super(TestCaseWithInterRepository, self).setUp()
159
 
        if self.extra_setup:
160
 
            self.extra_setup(self)
161
 
 
162
 
    def get_default_format(self):
163
 
        self.assertEquals(
164
 
            self.repository_format._matchingbzrdir.repository_format,
165
 
            self.repository_format)
166
 
        return self.repository_format._matchingbzrdir
167
135
 
168
136
    def make_branch(self, relpath, format=None):
169
137
        repo = self.make_repository(relpath, format=format)