1017
1017
self.assertEqualDiff(''.join(k.get_lines('text-1a')), TEXT_1A)
1018
1018
# check the index had the right data added.
1019
1019
self.assertEqual(set([
1020
('text-1', ' 0 127', ((), ())),
1021
('text-1a', ' 127 140', (('text-1',), ('text-1',))),
1020
(('text-1', ), ' 0 127', ((), ())),
1021
(('text-1a', ), ' 127 140', ((('text-1', ),), (('text-1', ),))),
1022
1022
]), set(index.iter_all_entries()))
1023
1023
# we should not have a .kndx file
1024
1024
self.assertFalse(get_transport('.').has('test.kndx'))
1622
1622
# build a complex graph across several indices.
1624
# delta compression inn the index
1624
1625
index1 = self.make_g_index('1', 2, [
1625
('tip', 'N0 100', (['parent'], [], )),
1626
('tail', '', ([], []))])
1626
(('tip', ), 'N0 100', ([('parent', )], [], )),
1627
(('tail', ), '', ([], []))])
1627
1628
index2 = self.make_g_index('2', 2, [
1628
('parent', ' 100 78', (['tail', 'ghost'], ['tail'])),
1629
('separate', '', ([], []))])
1629
(('parent', ), ' 100 78', ([('tail', ), ('ghost', )], [('tail', )])),
1630
(('separate', ), '', ([], []))])
1632
# just blob location and graph in the index.
1631
1633
index1 = self.make_g_index('1', 1, [
1632
('tip', 'N0 100', (['parent'], )),
1633
('tail', '', ([], ))])
1634
(('tip', ), 'N0 100', ([('parent', )], )),
1635
(('tail', ), '', ([], ))])
1634
1636
index2 = self.make_g_index('2', 1, [
1635
('parent', ' 100 78', (['tail', 'ghost'], )),
1636
('separate', '', ([], ))])
1637
(('parent', ), ' 100 78', ([('tail', ), ('ghost', )], )),
1638
(('separate', ), '', ([], ))])
1637
1639
combined_index = CombinedGraphIndex([index1, index2])
1639
1641
self.combined_index = combined_index
1777
1779
def test_add_version_smoke(self):
1778
1780
index = self.two_graph_index(catch_adds=True)
1779
1781
index.add_version('new', 'fulltext,no-eol', 50, 60, ['separate'])
1780
self.assertEqual([[('new', 'N50 60', (('separate',),))]],
1782
self.assertEqual([[(('new', ), 'N50 60', ((('separate',),),))]],
1781
1783
self.caught_entries)
1783
1785
def test_add_version_delta_not_delta_index(self):
1819
1821
('new', 'fulltext,no-eol', 50, 60, ['separate']),
1820
1822
('new2', 'fulltext', 0, 6, ['new']),
1822
self.assertEqual([('new', 'N50 60', (('separate',),)),
1823
('new2', ' 0 6', (('new',),))],
1824
self.assertEqual([(('new', ), 'N50 60', ((('separate',),),)),
1825
(('new2', ), ' 0 6', ((('new',),),))],
1824
1826
sorted(self.caught_entries[0]))
1825
1827
self.assertEqual(1, len(self.caught_entries))
1830
1832
('new', 'fulltext,no-eol', 50, 60, ['separate']),
1831
1833
('new2', 'line-delta', 0, 6, ['new']),
1833
self.assertEqual([('new', 'N50 60', (('separate',), ())),
1834
('new2', ' 0 6', (('new',), ('new',), ))],
1835
self.assertEqual([(('new', ), 'N50 60', ((('separate',),), ())),
1836
(('new2', ), ' 0 6', ((('new',),), (('new',),), ))],
1835
1837
sorted(self.caught_entries[0]))
1836
1838
self.assertEqual(1, len(self.caught_entries))
1875
1877
def test_iter_parents(self):
1876
1878
index1 = self.make_g_index('1', 1, [
1878
('r0', 'N0 100', ([], )),
1880
(('r0', ), 'N0 100', ([], )),
1880
('r1', '', (['r0'], ))])
1882
(('r1', ), '', ([('r0', )], ))])
1881
1883
index2 = self.make_g_index('2', 1, [
1883
('r2', 'N0 100', (['r1', 'r0'], )),
1885
(('r2', ), 'N0 100', ([('r1', ), ('r0', )], )),
1885
1887
combined_index = CombinedGraphIndex([index1, index2])
1886
1888
index = KnitGraphIndex(combined_index)
1932
1934
# put several versions in the index.
1933
1935
index1 = self.make_g_index('1', 0, [
1936
(('tip', ), 'N0 100'),
1936
1938
index2 = self.make_g_index('2', 0, [
1937
('parent', ' 100 78'),
1939
(('parent', ), ' 100 78'),
1940
(('separate', ), '')])
1939
1941
combined_index = CombinedGraphIndex([index1, index2])
1941
1943
self.combined_index = combined_index
2046
2048
def test_add_version_smoke(self):
2047
2049
index = self.two_graph_index(catch_adds=True)
2048
2050
index.add_version('new', 'fulltext,no-eol', 50, 60, [])
2049
self.assertEqual([[('new', 'N50 60')]],
2051
self.assertEqual([[(('new', ), 'N50 60')]],
2050
2052
self.caught_entries)
2052
2054
def test_add_version_delta_not_delta_index(self):
2088
2090
('new', 'fulltext,no-eol', 50, 60, []),
2089
2091
('new2', 'fulltext', 0, 6, []),
2091
self.assertEqual([('new', 'N50 60'), ('new2', ' 0 6')],
2093
self.assertEqual([(('new', ), 'N50 60'), (('new2', ), ' 0 6')],
2092
2094
sorted(self.caught_entries[0]))
2093
2095
self.assertEqual(1, len(self.caught_entries))