153
154
r = BzrDir.open_from_transport(t.clone('stackable')).open_repository()
154
155
self.assertTrue(r._format.supports_external_lookups)
157
def test_remote_branch_set_append_revisions_only(self):
158
# Make a format 1.9 branch, which supports append_revisions_only
159
branch = self.make_branch('branch', format='1.9')
160
config = branch.get_config()
161
branch.set_append_revisions_only(True)
163
'True', config.get_user_option('append_revisions_only'))
164
branch.set_append_revisions_only(False)
166
'False', config.get_user_option('append_revisions_only'))
168
def test_remote_branch_set_append_revisions_only_upgrade_reqd(self):
169
branch = self.make_branch('branch', format='knit')
170
config = branch.get_config()
172
errors.UpgradeRequired, branch.set_append_revisions_only, True)
157
175
class FakeProtocol(object):
158
176
"""Lookalike SmartClientRequestProtocolOne allowing body reading tests."""
2018
2040
self.assertEqual(('AnUnexpectedError',), e.error_tuple)
2043
class TestRepositoryGetRevIdForRevno(TestRemoteRepository):
2046
repo, client = self.setup_fake_client_and_repository('quack')
2047
client.add_expected_call(
2048
'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')),
2049
'success', ('ok', 'rev-five'))
2050
result = repo.get_rev_id_for_revno(5, (42, 'rev-foo'))
2051
self.assertEqual((True, 'rev-five'), result)
2052
self.assertFinished(client)
2054
def test_history_incomplete(self):
2055
repo, client = self.setup_fake_client_and_repository('quack')
2056
client.add_expected_call(
2057
'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')),
2058
'success', ('history-incomplete', 10, 'rev-ten'))
2059
result = repo.get_rev_id_for_revno(5, (42, 'rev-foo'))
2060
self.assertEqual((False, (10, 'rev-ten')), result)
2061
self.assertFinished(client)
2063
def test_history_incomplete_with_fallback(self):
2064
"""A 'history-incomplete' response causes the fallback repository to be
2065
queried too, if one is set.
2067
# Make a repo with a fallback repo, both using a FakeClient.
2068
format = remote.response_tuple_to_repo_format(
2069
('yes', 'no', 'yes', 'fake-network-name'))
2070
repo, client = self.setup_fake_client_and_repository('quack')
2071
repo._format = format
2072
fallback_repo, ignored = self.setup_fake_client_and_repository(
2074
fallback_repo._client = client
2075
repo.add_fallback_repository(fallback_repo)
2076
# First the client should ask the primary repo
2077
client.add_expected_call(
2078
'Repository.get_rev_id_for_revno', ('quack/', 1, (42, 'rev-foo')),
2079
'success', ('history-incomplete', 2, 'rev-two'))
2080
# Then it should ask the fallback, using revno/revid from the
2081
# history-incomplete response as the known revno/revid.
2082
client.add_expected_call(
2083
'Repository.get_rev_id_for_revno',('fallback/', 1, (2, 'rev-two')),
2084
'success', ('ok', 'rev-one'))
2085
result = repo.get_rev_id_for_revno(1, (42, 'rev-foo'))
2086
self.assertEqual((True, 'rev-one'), result)
2087
self.assertFinished(client)
2089
def test_nosuchrevision(self):
2090
# 'nosuchrevision' is returned when the known-revid is not found in the
2091
# remote repo. The client translates that response to NoSuchRevision.
2092
repo, client = self.setup_fake_client_and_repository('quack')
2093
client.add_expected_call(
2094
'Repository.get_rev_id_for_revno', ('quack/', 5, (42, 'rev-foo')),
2095
'error', ('nosuchrevision', 'rev-foo'))
2097
errors.NoSuchRevision,
2098
repo.get_rev_id_for_revno, 5, (42, 'rev-foo'))
2099
self.assertFinished(client)
2021
2102
class TestRepositoryIsShared(TestRemoteRepository):
2023
2104
def test_is_shared(self):