/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/branch_implementations/test_hooks.py

  • Committer: Robert Collins
  • Date: 2009-02-24 08:09:17 UTC
  • mfrom: (4037 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4038.
  • Revision ID: robertc@robertcollins.net-20090224080917-9k7ib4oj1godlp3k
Merge bzr (resolve conflicts).

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
 
77
77
    def capture_set_rh_hook(self, branch, rev_history):
78
78
        """Capture post set-rh hook calls to self.hook_calls.
79
 
        
 
79
 
80
80
        The call is logged, as is some state of the branch.
81
81
        """
82
82
        self.hook_calls.append(
200
200
 
201
201
class TestPreChangeBranchTip(ChangeBranchTipTestCase):
202
202
    """Tests for pre_change_branch_tip hook.
203
 
    
 
203
 
204
204
    Most of these tests are very similar to the tests in
205
205
    TestPostChangeBranchTip.
206
206
    """
218
218
 
219
219
    def test_hook_failure_prevents_change(self):
220
220
        """If a hook raises an exception, the change does not take effect.
221
 
        
 
221
 
222
222
        Also, a HookFailed exception will be raised.
223
223
        """
224
224
        branch = self.make_branch_with_revision_ids(
234
234
        self.assertIsInstance(hook_failed_exc.exc_value, PearShapedError)
235
235
        # The revision info is unchanged.
236
236
        self.assertEqual((2, 'two-\xc2\xb5'), branch.last_revision_info())
237
 
        
 
237
 
238
238
    def test_empty_history(self):
239
239
        branch = self.make_branch('source')
240
240
        hook_calls = self.install_logging_hook('pre')
282
282
 
283
283
    def test_explicit_reject_by_hook(self):
284
284
        """If a hook raises TipChangeRejected, the change does not take effect.
285
 
        
 
285
 
286
286
        TipChangeRejected exceptions are propagated, not wrapped in HookFailed.
287
287
        """
288
288
        branch = self.make_branch_with_revision_ids(
295
295
            TipChangeRejected, branch.set_last_revision_info, 0, NULL_REVISION)
296
296
        # The revision info is unchanged.
297
297
        self.assertEqual((2, 'two-\xc2\xb5'), branch.last_revision_info())
298
 
        
 
298
 
299
299
 
300
300
class TestPostChangeBranchTip(ChangeBranchTipTestCase):
301
301
    """Tests for post_change_branch_tip hook.
370
370
    def setUp(self):
371
371
        ChangeBranchTipTestCase.setUp(self)
372
372
        self.installPreAndPostHooks()
373
 
        
 
373
 
374
374
    def installPreAndPostHooks(self):
375
375
        self.pre_hook_calls = self.install_logging_hook('pre')
376
376
        self.post_hook_calls = self.install_logging_hook('post')