1143
1143
[('set_tags_bytes', 'tags bytes')] * 2, real_branch.calls)
1146
class TestBranchHeadsToFetch(RemoteBranchTestCase):
1148
def test_uses_last_revision_info_and_tags_by_default(self):
1149
transport = MemoryTransport()
1150
client = FakeClient(transport.base)
1151
client.add_expected_call(
1152
'Branch.get_stacked_on_url', ('quack/',),
1153
'error', ('NotStacked',))
1154
client.add_expected_call(
1155
'Branch.last_revision_info', ('quack/',),
1156
'success', ('ok', '1', 'rev-tip'))
1157
# XXX: this will break if the default format's serialization of tags
1158
# changes, or if the RPC for fetching tags changes from get_tags_bytes.
1159
client.add_expected_call(
1160
'Branch.get_tags_bytes', ('quack/',),
1161
'success', ('d5:tag-17:rev-foo5:tag-27:rev-bare',))
1162
transport.mkdir('quack')
1163
transport = transport.clone('quack')
1164
branch = self.make_remote_branch(transport, client)
1165
result = branch.heads_to_fetch()
1166
self.assertFinished(client)
1168
(set(['rev-tip']), set(['rev-foo', 'rev-bar'])), result)
1170
def test_uses_rpc_for_formats_with_non_default_heads_to_fetch(self):
1171
transport = MemoryTransport()
1172
client = FakeClient(transport.base)
1173
client.add_expected_call(
1174
'Branch.get_stacked_on_url', ('quack/',),
1175
'error', ('NotStacked',))
1176
client.add_expected_call(
1177
'Branch.heads_to_fetch', ('quack/',),
1178
'success', (['tip'], ['tagged-1', 'tagged-2']))
1179
transport.mkdir('quack')
1180
transport = transport.clone('quack')
1181
branch = self.make_remote_branch(transport, client)
1182
branch._format._use_default_local_heads_to_fetch = lambda: False
1183
result = branch.heads_to_fetch()
1184
self.assertFinished(client)
1185
self.assertEqual((set(['tip']), set(['tagged-1', 'tagged-2'])), result)
1187
def test_backwards_compatible(self):
1188
self.setup_smart_server_with_call_log()
1189
# Make a branch with a single revision.
1190
builder = self.make_branch_builder('foo')
1191
builder.start_series()
1192
builder.build_snapshot('tip', None, [
1193
('add', ('', 'root-id', 'directory', ''))])
1194
builder.finish_series()
1195
branch = builder.get_branch()
1196
# Add two tags to that branch
1197
branch.tags.set_tag('tag-1', 'rev-1')
1198
branch.tags.set_tag('tag-2', 'rev-2')
1199
self.addCleanup(branch.lock_read().unlock)
1200
# Disable the heads_to_fetch verb
1201
verb = 'Branch.heads_to_fetch'
1202
self.disable_verb(verb)
1203
self.reset_smart_call_log()
1204
result = branch.heads_to_fetch()
1205
self.assertEqual((set(['tip']), set(['rev-1', 'rev-2'])), result)
1207
['Branch.last_revision_info', 'Branch.get_tags_bytes'],
1208
[call.call.method for call in self.hpss_calls])
1146
1211
class TestBranchLastRevisionInfo(RemoteBranchTestCase):
1148
1213
def test_empty_branch(self):