1601
1610
(('tip',), 'line-delta', (None, 0, 100), [('parent',)])])
1602
1611
self.assertEqual([], self.caught_entries)
1613
def make_g_index_missing_compression_parent(self):
1614
graph_index = self.make_g_index('missing_comp', 2,
1615
[(('tip', ), ' 100 78',
1616
([('missing-parent', ), ('ghost', )], [('missing-parent', )]))])
1619
def make_g_index_no_external_refs(self):
1620
graph_index = self.make_g_index('no_external_refs', 2,
1621
[(('rev', ), ' 100 78',
1622
([('parent', ), ('ghost', )], []))])
1625
def test_add_good_unvalidated_index(self):
1626
unvalidated = self.make_g_index_no_external_refs()
1627
combined = CombinedGraphIndex([unvalidated])
1628
index = _KnitGraphIndex(combined, lambda: True, deltas=True)
1629
index.scan_unvalidated_index(unvalidated)
1630
self.assertEqual(frozenset(), index.get_missing_compression_parents())
1632
def test_add_incomplete_unvalidated_index(self):
1633
unvalidated = self.make_g_index_missing_compression_parent()
1634
combined = CombinedGraphIndex([unvalidated])
1635
index = _KnitGraphIndex(combined, lambda: True, deltas=True)
1636
index.scan_unvalidated_index(unvalidated)
1637
# This also checks that its only the compression parent that is
1638
# examined, otherwise 'ghost' would also be reported as a missing
1641
frozenset([('missing-parent',)]),
1642
index.get_missing_compression_parents())
1644
def test_add_unvalidated_index_with_present_external_references(self):
1645
index = self.two_graph_index(deltas=True)
1646
# Ugly hack to get at one of the underlying GraphIndex objects that
1647
# two_graph_index built.
1648
unvalidated = index._graph_index._indices[1]
1649
# 'parent' is an external ref of _indices[1] (unvalidated), but is
1650
# present in _indices[0].
1651
index.scan_unvalidated_index(unvalidated)
1652
self.assertEqual(frozenset(), index.get_missing_compression_parents())
1654
def make_new_missing_parent_g_index(self, name):
1655
missing_parent = name + '-missing-parent'
1656
graph_index = self.make_g_index(name, 2,
1657
[((name + 'tip', ), ' 100 78',
1658
([(missing_parent, ), ('ghost', )], [(missing_parent, )]))])
1661
def test_add_mulitiple_unvalidated_indices_with_missing_parents(self):
1662
g_index_1 = self.make_new_missing_parent_g_index('one')
1663
g_index_2 = self.make_new_missing_parent_g_index('two')
1664
combined = CombinedGraphIndex([g_index_1, g_index_2])
1665
index = _KnitGraphIndex(combined, lambda: True, deltas=True)
1666
index.scan_unvalidated_index(g_index_1)
1667
index.scan_unvalidated_index(g_index_2)
1669
frozenset([('one-missing-parent',), ('two-missing-parent',)]),
1670
index.get_missing_compression_parents())
1672
def test_add_mulitiple_unvalidated_indices_with_mutual_dependencies(self):
1673
graph_index_a = self.make_g_index('one', 2,
1674
[(('parent-one', ), ' 100 78', ([('non-compression-parent',)], [])),
1675
(('child-of-two', ), ' 100 78',
1676
([('parent-two',)], [('parent-two',)]))])
1677
graph_index_b = self.make_g_index('two', 2,
1678
[(('parent-two', ), ' 100 78', ([('non-compression-parent',)], [])),
1679
(('child-of-one', ), ' 100 78',
1680
([('parent-one',)], [('parent-one',)]))])
1681
combined = CombinedGraphIndex([graph_index_a, graph_index_b])
1682
index = _KnitGraphIndex(combined, lambda: True, deltas=True)
1683
index.scan_unvalidated_index(graph_index_a)
1684
index.scan_unvalidated_index(graph_index_b)
1686
frozenset([]), index.get_missing_compression_parents())
1605
1689
class TestNoParentsGraphIndexKnit(KnitTests):
1606
1690
"""Tests for knits using _KnitGraphIndex with no parents."""