/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-25 15:19:45 UTC
  • mfrom: (3577.1.3 tip-change-rejected-error)
  • Revision ID: pqm@pqm.ubuntu.com-20080725151945-kdaru30ix1m8k0h6
Add TipChangeRejected error so that pre_change_branch_tip hook
        functions can cleanly reject a change. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    tests,
37
37
    urlutils,
38
38
    )
39
 
from bzrlib.branch import BranchReferenceFormat
 
39
from bzrlib.branch import Branch, BranchReferenceFormat
40
40
import bzrlib.smart.branch
41
41
import bzrlib.smart.bzrdir
42
42
import bzrlib.smart.repository
480
480
        self.assertEqual(
481
481
            (1, rev_id_utf8), self.tree.branch.last_revision_info())
482
482
 
 
483
    def test_TipChangeRejected(self):
 
484
        """If a pre_change_branch_tip hook raises TipChangeRejected, the verb
 
485
        returns TipChangeRejected.
 
486
        """
 
487
        rejection_message = u'rejection message\N{INTERROBANG}'
 
488
        def hook_that_rejects(params):
 
489
            raise errors.TipChangeRejected(rejection_message)
 
490
        Branch.hooks.install_named_hook(
 
491
            'pre_change_branch_tip', hook_that_rejects, None)
 
492
        self.assertEqual(
 
493
            FailedSmartServerResponse(
 
494
                ('TipChangeRejected', rejection_message.encode('utf-8'))),
 
495
            self.set_last_revision('null:', 0))
 
496
 
483
497
 
484
498
class TestSmartServerBranchRequestSetLastRevision(
485
499
        SetLastRevisionTestBase, TestSetLastRevisionVerbMixin):