369
369
tree = self.make_branch_and_memory_tree('tree')
370
370
tree.lock_write()
371
self.addCleanup(tree.branch.repository.unlock)
371
self.addCleanup(tree.unlock)
372
372
tree.add([''], ['root-id'])
373
373
tree.commit('one', rev_id='rev-1')
374
374
tree.commit('two', rev_id='rev-2')
1637
1636
([('missing-parent', ), ('ghost', )], [('missing-parent', )]))])
1638
1637
return graph_index
1639
def make_g_index_missing_parent(self):
1640
graph_index = self.make_g_index('missing_parent', 2,
1641
[(('parent', ), ' 100 78', ([], [])),
1642
(('tip', ), ' 100 78',
1643
([('parent', ), ('missing-parent', )], [('parent', )])),
1640
1647
def make_g_index_no_external_refs(self):
1641
1648
graph_index = self.make_g_index('no_external_refs', 2,
1642
1649
[(('rev', ), ' 100 78',
1650
1657
index.scan_unvalidated_index(unvalidated)
1651
1658
self.assertEqual(frozenset(), index.get_missing_compression_parents())
1653
def test_add_incomplete_unvalidated_index(self):
1660
def test_add_missing_compression_parent_unvalidated_index(self):
1654
1661
unvalidated = self.make_g_index_missing_compression_parent()
1655
1662
combined = CombinedGraphIndex([unvalidated])
1656
1663
index = _KnitGraphIndex(combined, lambda: True, deltas=True)
1662
1669
frozenset([('missing-parent',)]),
1663
1670
index.get_missing_compression_parents())
1672
def test_add_missing_noncompression_parent_unvalidated_index(self):
1673
unvalidated = self.make_g_index_missing_parent()
1674
combined = CombinedGraphIndex([unvalidated])
1675
index = _KnitGraphIndex(combined, lambda: True, deltas=True,
1676
track_external_parent_refs=True)
1677
index.scan_unvalidated_index(unvalidated)
1679
frozenset([('missing-parent',)]), index.get_missing_parents())
1681
def test_track_external_parent_refs(self):
1682
g_index = self.make_g_index('empty', 2, [])
1683
combined = CombinedGraphIndex([g_index])
1684
index = _KnitGraphIndex(combined, lambda: True, deltas=True,
1685
add_callback=self.catch_add, track_external_parent_refs=True)
1686
self.caught_entries = []
1688
(('new-key',), 'fulltext,no-eol', (None, 50, 60),
1689
[('parent-1',), ('parent-2',)])])
1691
frozenset([('parent-1',), ('parent-2',)]),
1692
index.get_missing_parents())
1665
1694
def test_add_unvalidated_index_with_present_external_references(self):
1666
1695
index = self.two_graph_index(deltas=True)
1667
1696
# Ugly hack to get at one of the underlying GraphIndex objects that