1577
1578
self.assertEqual({r1: (NULL_REVISION,)}, parents)
1578
1579
self.assertEqual(
1579
1580
[('call_with_body_bytes_expecting_body',
1580
'Repository.get_parent_map', ('quack/', r2), '\n\n0')],
1581
'Repository.get_parent_map', ('quack/', 'include-missing:', r2),
1583
1585
# now we call again, and it should use the second response.
1587
1589
self.assertEqual({r1: (NULL_REVISION,)}, parents)
1588
1590
self.assertEqual(
1589
1591
[('call_with_body_bytes_expecting_body',
1590
'Repository.get_parent_map', ('quack/', r2), '\n\n0'),
1592
'Repository.get_parent_map', ('quack/', 'include-missing:', r2),
1591
1594
('call_with_body_bytes_expecting_body',
1592
'Repository.get_parent_map', ('quack/', r1), '\n\n0'),
1595
'Repository.get_parent_map', ('quack/', 'include-missing:', r1),
1604
1608
parents = repo.get_parent_map([rev_id])
1605
1609
self.assertEqual(
1606
1610
[('call_with_body_bytes_expecting_body',
1607
'Repository.get_parent_map', ('quack/', rev_id), '\n\n0'),
1611
'Repository.get_parent_map', ('quack/', 'include-missing:',
1608
1613
('disconnect medium',),
1609
1614
('call_expecting_body', 'Repository.get_revision_graph',
1610
1615
('quack/', ''))],
1643
1648
errors.UnexpectedSmartServerResponse,
1644
1649
repo.get_parent_map, ['a-revision-id'])
1651
def test_get_parent_map_negative_caches_missing_keys(self):
1652
self.setup_smart_server_with_call_log()
1653
repo = self.make_repository('foo')
1654
self.assertIsInstance(repo, RemoteRepository)
1656
self.addCleanup(repo.unlock)
1657
self.reset_smart_call_log()
1658
graph = repo.get_graph()
1659
self.assertEqual({},
1660
graph.get_parent_map(['some-missing', 'other-missing']))
1661
self.assertLength(1, self.hpss_calls)
1662
# No call if we repeat this
1663
self.reset_smart_call_log()
1664
graph = repo.get_graph()
1665
self.assertEqual({},
1666
graph.get_parent_map(['some-missing', 'other-missing']))
1667
self.assertLength(0, self.hpss_calls)
1668
# Asking for more unknown keys makes a request.
1669
self.reset_smart_call_log()
1670
graph = repo.get_graph()
1671
self.assertEqual({},
1672
graph.get_parent_map(['some-missing', 'other-missing',
1674
self.assertLength(1, self.hpss_calls)
1676
def test_get_parent_map_gets_ghosts_from_result(self):
1677
# asking for a revision should negatively cache close ghosts in its
1679
self.setup_smart_server_with_call_log()
1680
tree = self.make_branch_and_memory_tree('foo')
1683
builder = treebuilder.TreeBuilder()
1684
builder.start_tree(tree)
1686
builder.finish_tree()
1687
tree.set_parent_ids(['non-existant'], allow_leftmost_as_ghost=True)
1688
rev_id = tree.commit('')
1692
self.addCleanup(tree.unlock)
1693
repo = tree.branch.repository
1694
self.assertIsInstance(repo, RemoteRepository)
1696
repo.get_parent_map([rev_id])
1697
self.reset_smart_call_log()
1698
# Now asking for rev_id's ghost parent should not make calls
1699
self.assertEqual({}, repo.get_parent_map(['non-existant']))
1700
self.assertLength(0, self.hpss_calls)
1647
1703
class TestGetParentMapAllowsNew(tests.TestCaseWithTransport):
2363
2419
rev_ord, expected_revs = self.get_ordered_revs('knit', 'topological')
2364
2420
self.assertEqual(expected_revs, rev_ord)
2365
2421
# Getting topological sort requires VFS calls still
2366
self.assertLength(14, self.hpss_calls)
2422
self.assertLength(12, self.hpss_calls)
2368
2424
def test_stacked_get_stream_groupcompress(self):
2369
2425
# Repository._get_source.get_stream() from a stacked repository with