920
921
return make_file_factory(annotate, mapper)(self.get_transport())
924
class TestBadShaError(KnitTests):
925
"""Tests for handling of sha errors."""
927
def test_exception_has_text(self):
928
# having the failed text included in the error allows for recovery.
929
source = self.make_test_knit()
930
target = self.make_test_knit(name="target")
931
if not source._max_delta_chain:
932
raise TestNotApplicable(
933
"cannot get delta-caused sha failures without deltas.")
937
source.add_lines(basis, (), ['foo\n'])
938
source.add_lines(broken, (basis,), ['foo\n', 'bar\n'])
939
# Seed target with a bad basis text
940
target.add_lines(basis, (), ['gam\n'])
941
target.insert_record_stream(
942
source.get_record_stream([broken], 'unordered', False))
943
err = self.assertRaises(errors.KnitCorrupt,
944
target.get_record_stream([broken], 'unordered', True).next)
945
self.assertEqual(['gam\n', 'bar\n'], err.content)
946
# Test for formatting with live data
947
self.assertStartsWith(str(err), "Knit ")
923
950
class TestKnitIndex(KnitTests):
925
952
def test_add_versions_dictionary_compresses(self):