1629
1629
self.assertEqual({'rev1': ('null:',)}, graph.get_parent_map(['rev1']))
1632
class TestRepositoryGetRevisionGraph(TestRemoteRepository):
1634
def test_null_revision(self):
1635
# a null revision has the predictable result {}, we should have no wire
1636
# traffic when calling it with this argument
1637
transport_path = 'empty'
1638
repo, client = self.setup_fake_client_and_repository(transport_path)
1639
client.add_success_response('notused')
1640
# actual RemoteRepository.get_revision_graph is gone, but there's an
1641
# equivalent private method for testing
1642
result = repo._get_revision_graph(NULL_REVISION)
1643
self.assertEqual([], client._calls)
1644
self.assertEqual({}, result)
1646
def test_none_revision(self):
1647
# with none we want the entire graph
1648
r1 = u'\u0e33'.encode('utf8')
1649
r2 = u'\u0dab'.encode('utf8')
1650
lines = [' '.join([r2, r1]), r1]
1651
encoded_body = '\n'.join(lines)
1653
transport_path = 'sinhala'
1654
repo, client = self.setup_fake_client_and_repository(transport_path)
1655
client.add_success_response_with_body(encoded_body, 'ok')
1656
# actual RemoteRepository.get_revision_graph is gone, but there's an
1657
# equivalent private method for testing
1658
result = repo._get_revision_graph(None)
1660
[('call_expecting_body', 'Repository.get_revision_graph',
1663
self.assertEqual({r1: (), r2: (r1, )}, result)
1665
def test_specific_revision(self):
1666
# with a specific revision we want the graph for that
1667
# with none we want the entire graph
1668
r11 = u'\u0e33'.encode('utf8')
1669
r12 = u'\xc9'.encode('utf8')
1670
r2 = u'\u0dab'.encode('utf8')
1671
lines = [' '.join([r2, r11, r12]), r11, r12]
1672
encoded_body = '\n'.join(lines)
1674
transport_path = 'sinhala'
1675
repo, client = self.setup_fake_client_and_repository(transport_path)
1676
client.add_success_response_with_body(encoded_body, 'ok')
1677
result = repo._get_revision_graph(r2)
1679
[('call_expecting_body', 'Repository.get_revision_graph',
1682
self.assertEqual({r11: (), r12: (), r2: (r11, r12), }, result)
1684
def test_no_such_revision(self):
1686
transport_path = 'sinhala'
1687
repo, client = self.setup_fake_client_and_repository(transport_path)
1688
client.add_error_response('nosuchrevision', revid)
1689
# also check that the right revision is reported in the error
1690
self.assertRaises(errors.NoSuchRevision,
1691
repo._get_revision_graph, revid)
1693
[('call_expecting_body', 'Repository.get_revision_graph',
1694
('sinhala/', revid))],
1697
def test_unexpected_error(self):
1699
transport_path = 'sinhala'
1700
repo, client = self.setup_fake_client_and_repository(transport_path)
1701
client.add_error_response('AnUnexpectedError')
1702
e = self.assertRaises(errors.UnknownErrorFromSmartServer,
1703
repo._get_revision_graph, revid)
1704
self.assertEqual(('AnUnexpectedError',), e.error_tuple)
1632
1707
class TestRepositoryIsShared(TestRemoteRepository):
1634
1709
def test_is_shared(self):