1557
1559
self.assertRaises(RevisionNotPresent,
1558
1560
files.annotate, prefix + ('missing-key',))
1560
def test_get_annotator(self):
1562
def test_check_no_parameters(self):
1563
files = self.get_versionedfiles()
1565
def test_check_progressbar_parameter(self):
1566
"""A progress bar can be supplied because check can be a generator."""
1567
pb = ui.ui_factory.nested_progress_bar()
1568
self.addCleanup(pb.finished)
1569
files = self.get_versionedfiles()
1570
files.check(progress_bar=pb)
1572
def test_check_with_keys_becomes_generator(self):
1561
1573
files = self.get_versionedfiles()
1562
1574
self.get_diamond_files(files)
1563
origin_key = self.get_simple_key('origin')
1564
base_key = self.get_simple_key('base')
1565
left_key = self.get_simple_key('left')
1566
right_key = self.get_simple_key('right')
1567
merged_key = self.get_simple_key('merged')
1568
# annotator = files.get_annotator()
1569
# introduced full text
1570
origins, lines = files.get_annotator().annotate(origin_key)
1571
self.assertEqual([(origin_key,)], origins)
1572
self.assertEqual(['origin\n'], lines)
1574
origins, lines = files.get_annotator().annotate(base_key)
1575
self.assertEqual([(base_key,)], origins)
1577
origins, lines = files.get_annotator().annotate(merged_key)
1586
# Without a graph everything is new.
1593
self.assertRaises(RevisionNotPresent,
1594
files.get_annotator().annotate, self.get_simple_key('missing-key'))
1576
entries = files.check(keys=keys)
1578
# Texts output should be fulltexts.
1579
self.capture_stream(files, entries, seen.add,
1580
files.get_parent_map(keys), require_fulltext=True)
1581
# All texts should be output.
1582
self.assertEqual(set(keys), seen)
1596
1584
def test_construct(self):
1597
1585
"""Each parameterised test can be constructed on a transport."""
1750
1738
f.get_record_stream([key_b], 'unordered', True
1751
1739
).next().get_bytes_as('fulltext'))
1741
def test_get_known_graph_ancestry(self):
1742
f = self.get_versionedfiles()
1744
raise TestNotApplicable('ancestry info only relevant with graph.')
1745
key_a = self.get_simple_key('a')
1746
key_b = self.get_simple_key('b')
1747
key_c = self.get_simple_key('c')
1753
f.add_lines(key_a, [], ['\n'])
1754
f.add_lines(key_b, [key_a], ['\n'])
1755
f.add_lines(key_c, [key_a, key_b], ['\n'])
1756
kg = f.get_known_graph_ancestry([key_c])
1757
self.assertIsInstance(kg, _mod_graph.KnownGraph)
1758
self.assertEqual([key_a, key_b, key_c], list(kg.topo_sort()))
1760
def test_known_graph_with_fallbacks(self):
1761
f = self.get_versionedfiles('files')
1763
raise TestNotApplicable('ancestry info only relevant with graph.')
1764
if getattr(f, 'add_fallback_versioned_files', None) is None:
1765
raise TestNotApplicable("%s doesn't support fallbacks"
1766
% (f.__class__.__name__,))
1767
key_a = self.get_simple_key('a')
1768
key_b = self.get_simple_key('b')
1769
key_c = self.get_simple_key('c')
1770
# A only in fallback
1775
g = self.get_versionedfiles('fallback')
1776
g.add_lines(key_a, [], ['\n'])
1777
f.add_fallback_versioned_files(g)
1778
f.add_lines(key_b, [key_a], ['\n'])
1779
f.add_lines(key_c, [key_a, key_b], ['\n'])
1780
kg = f.get_known_graph_ancestry([key_c])
1781
self.assertEqual([key_a, key_b, key_c], list(kg.topo_sort()))
1753
1783
def test_get_record_stream_empty(self):
1754
1784
"""An empty stream can be requested without error."""
1755
1785
f = self.get_versionedfiles()
1766
1796
'knit-delta-closure', 'knit-delta-closure-ref',
1767
1797
'groupcompress-block', 'groupcompress-block-ref'])
1769
def capture_stream(self, f, entries, on_seen, parents):
1799
def capture_stream(self, f, entries, on_seen, parents,
1800
require_fulltext=False):
1770
1801
"""Capture a stream for testing."""
1771
1802
for factory in entries:
1772
1803
on_seen(factory.key)
1777
1808
self.assertEqual(parents[factory.key], factory.parents)
1778
1809
self.assertIsInstance(factory.get_bytes_as(factory.storage_kind),
1811
if require_fulltext:
1812
factory.get_bytes_as('fulltext')
1781
1814
def test_get_record_stream_interface(self):
1782
1815
"""each item in a stream has to provide a regular interface."""
2193
def test_get_annotator(self):
2194
files = self.get_versionedfiles()
2195
self.get_diamond_files(files)
2196
origin_key = self.get_simple_key('origin')
2197
base_key = self.get_simple_key('base')
2198
left_key = self.get_simple_key('left')
2199
right_key = self.get_simple_key('right')
2200
merged_key = self.get_simple_key('merged')
2201
# annotator = files.get_annotator()
2202
# introduced full text
2203
origins, lines = files.get_annotator().annotate(origin_key)
2204
self.assertEqual([(origin_key,)], origins)
2205
self.assertEqual(['origin\n'], lines)
2207
origins, lines = files.get_annotator().annotate(base_key)
2208
self.assertEqual([(base_key,)], origins)
2210
origins, lines = files.get_annotator().annotate(merged_key)
2219
# Without a graph everything is new.
2226
self.assertRaises(RevisionNotPresent,
2227
files.get_annotator().annotate, self.get_simple_key('missing-key'))
2160
2229
def test_get_parent_map(self):
2161
2230
files = self.get_versionedfiles()
2162
2231
if self.key_length == 1:
2637
2706
self.assertRaises(NotImplementedError,
2638
2707
self.texts.add_mpdiffs, [])
2640
def test_check(self):
2641
self.assertTrue(self.texts.check())
2709
def test_check_noerrors(self):
2643
2712
def test_insert_record_stream(self):
2644
2713
self.assertRaises(NotImplementedError, self.texts.insert_record_stream,