~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_commit.py

(igc) post_commit hook for MutableTree

Show diffs side-by-side

added added

removed removed

Lines of Context:
611
611
        revid = tree.commit('first post')
612
612
        committed_tree = tree.basis_tree()
613
613
        self.assertTrue(committed_tree.has_filename("newfile"))
 
614
 
 
615
    def test_post_commit_hook(self):
 
616
        """Make sure a post_commit hook is called after a commit."""
 
617
        def post_commit_hook_test_params(params):
 
618
            self.assertTrue(isinstance(params,
 
619
                mutabletree.PostCommitHookParams))
 
620
            self.assertTrue(isinstance(params.mutable_tree,
 
621
                mutabletree.MutableTree))
 
622
            open(tree.abspath("newfile"), 'w').write("data")
 
623
            params.mutable_tree.add(["newfile"])
 
624
        def restoreDefaults():
 
625
            mutabletree.MutableTree.hooks['post_commit'] = []
 
626
        self.addCleanup(restoreDefaults)
 
627
        tree = self.make_branch_and_tree('.')
 
628
        mutabletree.MutableTree.hooks.install_named_hook(
 
629
            'post_commit',
 
630
            post_commit_hook_test_params,
 
631
            None)
 
632
        self.assertFalse(tree.has_filename("newfile"))
 
633
        revid = tree.commit('first post')
 
634
        self.assertTrue(tree.has_filename("newfile"))
 
635
        committed_tree = tree.basis_tree()
 
636
        self.assertFalse(committed_tree.has_filename("newfile"))