551
551
errors.NoSuchRevision, branch.set_revision_history, ['rev-id'])
554
def test_tip_change_rejected(self):
555
"""TipChangeRejected responses cause a TipChangeRejected exception to
558
transport = MemoryTransport()
559
transport.mkdir('branch')
560
transport = transport.clone('branch')
561
client = FakeClient(transport.base)
563
client.add_success_response('ok', 'branch token', 'repo token')
565
rejection_msg_unicode = u'rejection message\N{INTERROBANG}'
566
rejection_msg_utf8 = rejection_msg_unicode.encode('utf8')
567
client.add_error_response('TipChangeRejected', rejection_msg_utf8)
569
client.add_success_response('ok')
571
bzrdir = RemoteBzrDir(transport, _client=False)
572
repo = RemoteRepository(bzrdir, None, _client=client)
573
branch = RemoteBranch(bzrdir, repo, _client=client)
574
branch._ensure_real = lambda: None
576
self.addCleanup(branch.unlock)
579
# The 'TipChangeRejected' error response triggered by calling
580
# set_revision_history causes a TipChangeRejected exception.
581
err = self.assertRaises(
582
errors.TipChangeRejected, branch.set_revision_history, ['rev-id'])
583
# The UTF-8 message from the response has been decoded into a unicode
585
self.assertIsInstance(err.msg, unicode)
586
self.assertEqual(rejection_msg_unicode, err.msg)
555
589
class TestBranchSetLastRevisionInfo(tests.TestCase):
689
723
self.assertEqual(('UnexpectedError',), err.error_tuple)
726
def test_tip_change_rejected(self):
727
"""TipChangeRejected responses cause a TipChangeRejected exception to
730
transport = MemoryTransport()
731
transport.mkdir('branch')
732
transport = transport.clone('branch')
733
client = FakeClient(transport.base)
735
client.add_success_response('ok', 'branch token', 'repo token')
737
client.add_error_response('TipChangeRejected', 'rejection message')
739
client.add_success_response('ok')
741
bzrdir = RemoteBzrDir(transport, _client=False)
742
repo = RemoteRepository(bzrdir, None, _client=client)
743
branch = RemoteBranch(bzrdir, repo, _client=client)
744
# This is a hack to work around the problem that RemoteBranch currently
745
# unnecessarily invokes _ensure_real upon a call to lock_write.
746
branch._ensure_real = lambda: None
747
# Lock the branch, reset the record of remote calls.
749
self.addCleanup(branch.unlock)
752
# The 'TipChangeRejected' error response triggered by calling
753
# set_last_revision_info causes a TipChangeRejected exception.
754
err = self.assertRaises(
755
errors.TipChangeRejected,
756
branch.set_last_revision_info, 123, 'revid')
757
self.assertEqual('rejection message', err.msg)
693
760
class TestBranchControlGetBranchConf(tests.TestCaseWithMemoryTransport):
694
761
"""Getting the branch configuration should use an abstract method not vfs.