94
95
ConstantMapper('inventory')),
98
'support_partial_insertion': False,
100
102
'factory':make_file_factory(False, ConstantMapper('revisions')),
105
'support_partial_insertion': True,
104
('named-nograph-knit-pack', {
107
('named-nograph-nodelta-knit-pack', {
105
108
'cleanup':cleanup_pack_knit,
106
109
'factory':make_pack_factory(False, False, 1),
112
'support_partial_insertion': False,
110
114
('named-graph-knit-pack', {
111
115
'cleanup':cleanup_pack_knit,
112
116
'factory':make_pack_factory(True, True, 1),
119
'support_partial_insertion': True,
116
121
('named-graph-nodelta-knit-pack', {
117
122
'cleanup':cleanup_pack_knit,
118
123
'factory':make_pack_factory(True, False, 1),
126
'support_partial_insertion': False,
123
129
len_two_adapter.scenarios = [
136
'support_partial_insertion': False,
131
138
('annotated-knit-escape', {
133
140
'factory':make_file_factory(True, HashEscapedPrefixMapper()),
143
'support_partial_insertion': False,
137
145
('plain-knit-pack', {
138
146
'cleanup':cleanup_pack_knit,
139
147
'factory':make_pack_factory(True, True, 2),
150
'support_partial_insertion': True,
144
153
for test in iter_suite_tests(to_adapt):
1970
1979
self.assertIdenticalVersionedFile(source, files)
1972
def test_insert_record_stream_delta_missing_basis_no_corruption(self):
1973
"""Insertion where a needed basis is not included aborts safely."""
1974
# We use a knit source with a graph always here to be sure we are
1975
# getting a binary delta.
1981
def get_knit_delta_source(self):
1982
"""Get a source that can produce a stream with knit delta records,
1983
regardless of this test's scenario.
1976
1985
mapper = self.get_mapper()
1977
1986
source_transport = self.get_transport('source')
1978
1987
source_transport.mkdir('.')
1979
1988
source = make_file_factory(False, mapper)(source_transport)
1980
1989
get_diamond_files(source, self.key_length, trailing_eol=True,
1981
1990
nograph=False, left_only=False)
1993
def test_insert_record_stream_delta_missing_basis_no_corruption(self):
1994
"""Insertion where a needed basis is not included notifies the caller
1995
of the missing basis. In the meantime a record missing its basis is
1998
source = self.get_knit_delta_source()
1982
1999
entries = source.get_record_stream([self.get_simple_key('origin'),
1983
2000
self.get_simple_key('merged')], 'unordered', False)
1984
2001
files = self.get_versionedfiles()
1985
self.assertRaises(RevisionNotPresent, files.insert_record_stream,
2002
self.assertEqual([], list(files.get_missing_compression_parent_keys()))
2003
if self.support_partial_insertion:
2004
files.insert_record_stream(entries)
2005
missing_bases = files.get_missing_compression_parent_keys()
2006
self.assertEqual(set([self.get_simple_key('left')]),
2010
errors.RevisionNotPresent, files.insert_record_stream, entries)
1988
2012
self.assertEqual({}, files.get_parent_map([]))
2014
def test_insert_record_stream_delta_missing_basis_can_be_added_later(self):
2015
"""Insertion where a needed basis is not included notifies the caller
2016
of the missing basis. That basis can be added in a second
2017
insert_record_stream call that does not need to repeat records present
2018
in the previous stream.
2020
if not self.support_partial_insertion:
2021
raise TestNotApplicable(
2022
'versioned file scenario does not support partial insertion')
2023
source = self.get_knit_delta_source()
2024
entries = source.get_record_stream([self.get_simple_key('origin'),
2025
self.get_simple_key('merged')], 'unordered', False)
2026
files = self.get_versionedfiles()
2027
files.insert_record_stream(entries)
2028
missing_bases = files.get_missing_compression_parent_keys()
2029
self.assertEqual(set([self.get_simple_key('left')]),
2031
# 'merged' is not yet inserted
2033
merged_key = self.get_simple_key('merged')
2034
self.assertEqual([], files.get_parent_map([merged_key]).keys())
2035
missing_entries = source.get_record_stream(
2036
[self.get_simple_key('left')], 'unordered', True)
2037
files.insert_record_stream(missing_entries)
2038
self.assertEqual([], list(files.get_missing_compression_parent_keys()))
2039
# Now 'merged' is fully inserted
2042
[merged_key], files.get_parent_map([merged_key]).keys())
1990
2044
def test_iter_lines_added_or_present_in_keys(self):
1991
2045
# test that we get at least an equalset of the lines added by
1992
2046
# versions in the store.