~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

  • Committer: Robert Collins
  • Date: 2005-10-20 02:52:44 UTC
  • Revision ID: robertc@robertcollins.net-20051020025244-fa1017d19a0ef618
post commit hook, first pass implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import os
19
19
 
 
20
import bzrlib
20
21
from bzrlib.selftest import TestCaseInTempDir
21
22
from bzrlib.branch import Branch
22
23
from bzrlib.workingtree import WorkingTree
36
37
        return ['cat', '-']
37
38
 
38
39
 
 
40
class BranchWithHooks(BranchConfig):
 
41
 
 
42
    def post_commit(self):
 
43
        return "bzrlib.ahook bzrlib.ahook"
 
44
 
 
45
 
39
46
class TestCommit(TestCaseInTempDir):
40
47
 
41
48
    def test_simple_commit(self):
318
325
            self.failIf(branch.revision_store.has_id('B'))
319
326
        finally:
320
327
            bzrlib.gpg.GPGStrategy = oldstrategy
 
328
 
 
329
    def test_commit_invokes_hooks(self):
 
330
        import bzrlib.commit as commit
 
331
        branch = Branch.initialize('.')
 
332
        calls = []
 
333
        def called(branch, rev_id):
 
334
            calls.append('called')
 
335
        bzrlib.ahook = called
 
336
        try:
 
337
            config = BranchWithHooks(branch)
 
338
            commit.Commit(config=config).commit(
 
339
                            branch, "base",
 
340
                            allow_pointless=True,
 
341
                            rev_id='A')
 
342
            self.assertEqual(['called', 'called'], calls)
 
343
        finally:
 
344
            del bzrlib.ahook