606
class TestSmartServerBranchRequestSetTagsBytes(TestLockedBranch):
607
# Only called when the branch format and tags match [yay factory
608
# methods] so only need to test straight forward cases.
610
def test_set_bytes(self):
611
base_branch = self.make_branch('base')
612
tag_bytes = base_branch._get_tags_bytes()
613
# get_lock_tokens takes out a lock.
614
branch_token, repo_token = self.get_lock_tokens(base_branch)
615
request = smart.branch.SmartServerBranchSetTagsBytes(
616
self.get_transport())
617
response = request.execute('base', branch_token, repo_token)
618
self.assertEqual(None, response)
619
response = request.do_chunk(tag_bytes)
620
self.assertEqual(None, response)
621
response = request.do_end()
623
SuccessfulSmartServerResponse(()), response)
626
def test_lock_failed(self):
627
base_branch = self.make_branch('base')
628
base_branch.lock_write()
629
tag_bytes = base_branch._get_tags_bytes()
630
request = smart.branch.SmartServerBranchSetTagsBytes(
631
self.get_transport())
632
self.assertRaises(errors.TokenMismatch, request.execute,
633
'base', 'wrong token', 'wrong token')
634
# The request handler will keep processing the message parts, so even
635
# if the request fails immediately do_chunk and do_end are still
637
request.do_chunk(tag_bytes)
606
643
class SetLastRevisionTestBase(TestLockedBranch):
607
644
"""Base test case for verbs that implement set_last_revision."""
874
911
class TestSmartServerBranchRequestGetTagsBytes(tests.TestCaseWithMemoryTransport):
875
# Only called when the branch format and tags match [yay factory
876
# methods] so only need to test straight forward cases.
912
# Only called when the branch format and tags match [yay factory
913
# methods] so only need to test straight forward cases.
878
915
def test_get_bytes(self):
879
916
base_branch = self.make_branch('base')
1161
1198
request.execute('', 'missingrevision'))
1201
class TestSmartServerRepositoryGetRevIdForRevno(tests.TestCaseWithMemoryTransport):
1203
def test_revno_found(self):
1204
backing = self.get_transport()
1205
request = smart.repository.SmartServerRepositoryGetRevIdForRevno(backing)
1206
tree = self.make_branch_and_memory_tree('.')
1209
rev1_id_utf8 = u'\xc8'.encode('utf-8')
1210
rev2_id_utf8 = u'\xc9'.encode('utf-8')
1211
tree.commit('1st commit', rev_id=rev1_id_utf8)
1212
tree.commit('2nd commit', rev_id=rev2_id_utf8)
1215
self.assertEqual(SmartServerResponse(('ok', rev1_id_utf8)),
1216
request.execute('', 1, (2, rev2_id_utf8)))
1218
def test_known_revid_missing(self):
1219
backing = self.get_transport()
1220
request = smart.repository.SmartServerRepositoryGetRevIdForRevno(backing)
1221
repo = self.make_repository('.')
1223
FailedSmartServerResponse(('nosuchrevision', 'ghost')),
1224
request.execute('', 1, (2, 'ghost')))
1226
def test_history_incomplete(self):
1227
backing = self.get_transport()
1228
request = smart.repository.SmartServerRepositoryGetRevIdForRevno(backing)
1229
parent = self.make_branch_and_memory_tree('parent', format='1.9')
1231
parent.add([''], ['TREE_ROOT'])
1232
r1 = parent.commit(message='first commit')
1233
r2 = parent.commit(message='second commit')
1235
local = self.make_branch_and_memory_tree('local', format='1.9')
1236
local.branch.pull(parent.branch)
1237
local.set_parent_ids([r2])
1238
r3 = local.commit(message='local commit')
1239
local.branch.create_clone_on_transport(
1240
self.get_transport('stacked'), stacked_on=self.get_url('parent'))
1242
SmartServerResponse(('history-incomplete', 2, r2)),
1243
request.execute('stacked', 1, (3, r3)))
1164
1245
class TestSmartServerRepositoryGetStream(tests.TestCaseWithMemoryTransport):
1166
1247
def make_two_commit_repo(self):
1576
1657
smart.repository.SmartServerRepositoryGatherStats)
1577
1658
self.assertHandlerEqual('Repository.get_parent_map',
1578
1659
smart.repository.SmartServerRepositoryGetParentMap)
1660
self.assertHandlerEqual('Repository.get_rev_id_for_revno',
1661
smart.repository.SmartServerRepositoryGetRevIdForRevno)
1579
1662
self.assertHandlerEqual('Repository.get_revision_graph',
1580
1663
smart.repository.SmartServerRepositoryGetRevisionGraph)
1581
1664
self.assertHandlerEqual('Repository.get_stream',