~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2008-04-07 08:20:13 UTC
  • mfrom: (3340 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3344.
  • Revision ID: andrew.bennetts@canonical.com-20080407082013-ca1n1tqqon7ugxiy
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"))