267
272
assert state in ('irrelevant', 'ghost-a', 'ghost-b', 'killed-base',
268
273
'killed-both'), \
277
class InterVersionedFile(InterObject):
278
"""This class represents operations taking place between two versionedfiles..
280
Its instances have methods like join, and contain
281
references to the source and target versionedfiles these operations can be
284
Often we will provide convenience methods on 'versionedfile' which carry out
285
operations with another versionedfile - they will always forward to
286
InterVersionedFile.get(other).method_name(parameters).
290
"""The available optimised InterVersionedFile types."""
293
class InterVersionedFileTestProviderAdapter(object):
294
"""A tool to generate a suite testing multiple inter versioned-file classes.
296
This is done by copying the test once for each interversionedfile provider
297
and injecting the transport_server, transport_readonly_server,
298
versionedfile_factory and versionedfile_factory_to classes into each copy.
299
Each copy is also given a new id() to make it easy to identify.
302
def __init__(self, transport_server, transport_readonly_server, formats):
303
self._transport_server = transport_server
304
self._transport_readonly_server = transport_readonly_server
305
self._formats = formats
307
def adapt(self, test):
309
for (interversionedfile_class,
310
versionedfile_factory,
311
versionedfile_factory_to) in self._formats:
312
new_test = deepcopy(test)
313
new_test.transport_server = self._transport_server
314
new_test.transport_readonly_server = self._transport_readonly_server
315
new_test.interversionedfile_class = interversionedfile_class
316
new_test.versionedfile_factory = versionedfile_factory
317
new_test.versionedfile_factory_to = versionedfile_factory_to
318
def make_new_test_id():
319
new_id = "%s(%s)" % (new_test.id(), interversionedfile_class.__name__)
320
return lambda: new_id
321
new_test.id = make_new_test_id()
322
result.addTest(new_test)
326
def default_test_list():
327
"""Generate the default list of interversionedfile permutations to test."""
328
from bzrlib.weave import WeaveFile
329
from bzrlib.knit import AnnotatedKnitFactory
331
# test the fallback InterVersionedFile from weave to annotated knits
332
result.append((InterVersionedFile,
334
AnnotatedKnitFactory))
335
for optimiser in InterVersionedFile._optimisers:
336
result.append((optimiser,
337
optimiser._matching_file_factory,
338
optimiser._matching_file_factory
340
# if there are specific combinations we want to use, we can add them