~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-23 19:08:05 UTC
  • mfrom: (6437.3.20 2.5)
  • mto: This revision was merged to the branch mainline in revision 6450.
  • Revision ID: jelmer@samba.org-20120123190805-hlcuihkt2dep44cw
merge bzr 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    pathjoin,
61
61
)
62
62
from bzrlib.merge import Merge3Merger, Merger
 
63
from bzrlib.mutabletree import MutableTree
63
64
from bzrlib.tests import (
64
65
    features,
65
66
    TestCaseInTempDir,
3717
3718
                         remaining_conflicts.pop())
3718
3719
        self.assertLength(1, warnings)
3719
3720
        self.assertStartsWith(warnings[0], 'donttouchmypreciouuus')
 
3721
 
 
3722
 
 
3723
class TestTransformHooks(tests.TestCaseWithTransport):
 
3724
 
 
3725
    def setUp(self):
 
3726
        super(TestTransformHooks, self).setUp()
 
3727
        self.wt = self.make_branch_and_tree('.')
 
3728
        os.chdir('..')
 
3729
 
 
3730
    def get_transform(self):
 
3731
        transform = TreeTransform(self.wt)
 
3732
        self.addCleanup(transform.finalize)
 
3733
        return transform, transform.root
 
3734
 
 
3735
    def test_pre_commit_hooks(self):
 
3736
        calls = []
 
3737
        def record_pre_transform(tree, tt):
 
3738
            calls.append((tree, tt))
 
3739
        MutableTree.hooks.install_named_hook('pre_transform',
 
3740
            record_pre_transform, "Pre transform")
 
3741
        transform, root = self.get_transform()
 
3742
        old_root_id = transform.tree_file_id(root)
 
3743
        transform.apply()
 
3744
        self.assertEqual(old_root_id, self.wt.get_root_id())
 
3745
        self.assertEquals([(self.wt, transform)], calls)
 
3746
 
 
3747
    def test_post_commit_hooks(self):
 
3748
        calls = []
 
3749
        def record_post_transform(tree, tt):
 
3750
            calls.append((tree, tt))
 
3751
        MutableTree.hooks.install_named_hook('post_transform',
 
3752
            record_post_transform, "Post transform")
 
3753
        transform, root = self.get_transform()
 
3754
        old_root_id = transform.tree_file_id(root)
 
3755
        transform.apply()
 
3756
        self.assertEqual(old_root_id, self.wt.get_root_id())
 
3757
        self.assertEquals([(self.wt, transform)], calls)