44
44
from bzrlib.symbol_versioning import one_four, one_five
45
from bzrlib.tests import TestCaseWithMemoryTransport, TestSkipped
45
from bzrlib.tests import (
46
TestCaseWithMemoryTransport,
50
split_suite_by_condition,
46
53
from bzrlib.tests.http_utils import TestCaseWithWebserver
47
54
from bzrlib.trace import mutter
48
55
from bzrlib.transport import get_transport
50
57
from bzrlib.tsort import topo_sort
51
58
from bzrlib.tuned_gzip import GzipFile
52
59
import bzrlib.versionedfile as versionedfile
60
from bzrlib.versionedfile import (
62
HashEscapedPrefixMapper,
65
make_versioned_files_factory,
53
67
from bzrlib.weave import WeaveFile
54
68
from bzrlib.weavefile import read_weave, write_weave
71
def load_tests(standard_tests, module, loader):
72
"""Parameterize VersionedFiles tests for different implementations."""
73
to_adapt, result = split_suite_by_condition(
74
standard_tests, condition_isinstance(TestVersionedFiles))
75
len_one_adapter = TestScenarioApplier()
76
len_two_adapter = TestScenarioApplier()
77
# We want to be sure of behaviour for:
78
# weaves prefix layout (weave texts)
79
# individually named weaves (weave inventories)
80
# annotated knits - prefix|hash|hash-escape layout, we test the third only
81
# as it is the most complex mapper.
82
# individually named knits
83
# individual no-graph knits in packs (signatures)
84
# individual graph knits in packs (inventories)
85
# individual graph nocompression knits in packs (revisions)
86
# plain text knits in packs (texts)
87
len_one_adapter.scenarios = [
89
'factory':make_versioned_files_factory(WeaveFile,
90
ConstantMapper('inventory')),
94
'factory':make_versioned_files_factory(make_file_knit,
95
ConstantMapper('revisions')),
98
('named-nograph-knit-pack', {
99
'factory':make_pack_factory(False, False, 1),
102
('named-graph-knit-pack', {
103
'factory':make_pack_factory(True, True, 1),
106
('named-graph-nodelta-knit-pack', {
107
'factory':make_pack_factory(True, False, 1),
111
len_two_adapter.scenarios = [
113
'factory':make_versioned_files_factory(WeaveFile,
117
('annotated-knit-escape', {
118
'factory':make_versioned_files_factory(make_file_knit,
119
HashEscapedPrefixMapper()),
122
('plain-knit-pack', {
123
'factory':make_pack_factory(True, True, 2),
127
for test in iter_suite_tests(to_adapt):
128
result.addTests(len_one_adapter.adapt(test))
129
result.addTests(len_two_adapter.adapt(test))
57
133
def get_diamond_vf(f, trailing_eol=True, left_only=False):
58
134
"""Get a diamond graph to exercise deltas and merges.
1580
1656
"revision-id")))
1581
1657
self.assertEqual(('filE-Id',), mapper.unmap("ed/fil%45-%49d"))
1582
1658
self.assertEqual(('neW-Id',), mapper.unmap("88/ne%57-%49d"))
1661
class TestVersionedFiles(TestCaseWithMemoryTransport):
1662
"""Tests for the multiple-file variant of VersionedFile."""
1664
def test_construct(self):
1665
"""Each parameterised test can be constructed on a transport."""
1666
files = self.factory(self.get_transport())