~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    bzrdir,
24
24
    conflicts,
25
25
    errors,
 
26
    mutabletree,
26
27
    osutils,
27
28
    revision as _mod_revision,
28
29
    ui,
536
537
             ],
537
538
            factory._calls
538
539
           )
 
540
 
 
541
    def test_start_commit_hook(self):
 
542
        """Make sure a start commit hook can modify the tree that is 
 
543
        committed."""
 
544
        def start_commit_hook_adds_file(tree):
 
545
            open(tree.abspath("newfile"), 'w').write("data")
 
546
            tree.add(["newfile"])
 
547
        def restoreDefaults():
 
548
            mutabletree.MutableTree.hooks['start_commit'] = []
 
549
        self.addCleanup(restoreDefaults)
 
550
        tree = self.make_branch_and_tree('.')
 
551
        mutabletree.MutableTree.hooks.install_hook('start_commit', 
 
552
            start_commit_hook_adds_file)
 
553
        revid = tree.commit('first post')
 
554
        committed_tree = tree.basis_tree()
 
555
        self.assertTrue(committed_tree.has_filename("newfile"))