~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2008-07-08 14:55:19 UTC
  • mfrom: (3530 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3532.
  • Revision ID: john@arbash-meinel.com-20080708145519-paqg4kjwbpgs2xmq
Merge bzr.dev 3530

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,
497
498
        ui.ui_factory = factory
498
499
        def a_hook(_, _2, _3, _4, _5, _6):
499
500
            pass
500
 
        branch.Branch.hooks.install_hook('post_commit', a_hook)
501
 
        branch.Branch.hooks.name_hook(a_hook, 'hook name')
 
501
        branch.Branch.hooks.install_named_hook('post_commit', a_hook,
 
502
                                               'hook name')
502
503
        tree.commit('first post')
503
504
        self.assertEqual(
504
505
            [('update', 1, 5, 'Collecting changes [Directory 0] - Stage'),
522
523
        ui.ui_factory = factory
523
524
        def a_hook(_, _2, _3, _4, _5, _6, _7, _8):
524
525
            pass
525
 
        branch.Branch.hooks.install_hook('pre_commit', a_hook)
526
 
        branch.Branch.hooks.name_hook(a_hook, 'hook name')
 
526
        branch.Branch.hooks.install_named_hook('pre_commit', a_hook,
 
527
                                               'hook name')
527
528
        tree.commit('first post')
528
529
        self.assertEqual(
529
530
            [('update', 1, 5, 'Collecting changes [Directory 0] - Stage'),
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_named_hook(
 
552
            'start_commit',
 
553
            start_commit_hook_adds_file,
 
554
            None)
 
555
        revid = tree.commit('first post')
 
556
        committed_tree = tree.basis_tree()
 
557
        self.assertTrue(committed_tree.has_filename("newfile"))