~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

Merge bzr.dev and tree-file-ids-as-tuples.

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,
3713
3714
                         remaining_conflicts.pop())
3714
3715
        self.assertLength(1, warnings)
3715
3716
        self.assertStartsWith(warnings[0], 'donttouchmypreciouuus')
 
3717
 
 
3718
 
 
3719
class TestTransformHooks(tests.TestCaseWithTransport):
 
3720
 
 
3721
    def setUp(self):
 
3722
        super(TestTransformHooks, self).setUp()
 
3723
        self.wt = self.make_branch_and_tree('.')
 
3724
        os.chdir('..')
 
3725
 
 
3726
    def get_transform(self):
 
3727
        transform = TreeTransform(self.wt)
 
3728
        self.addCleanup(transform.finalize)
 
3729
        return transform, transform.root
 
3730
 
 
3731
    def test_pre_commit_hooks(self):
 
3732
        calls = []
 
3733
        def record_pre_transform(tree, tt):
 
3734
            calls.append((tree, tt))
 
3735
        MutableTree.hooks.install_named_hook('pre_transform',
 
3736
            record_pre_transform, "Pre transform")
 
3737
        transform, root = self.get_transform()
 
3738
        old_root_id = transform.tree_file_id(root)
 
3739
        transform.apply()
 
3740
        self.assertEqual(old_root_id, self.wt.get_root_id())
 
3741
        self.assertEquals([(self.wt, transform)], calls)
 
3742
 
 
3743
    def test_post_commit_hooks(self):
 
3744
        calls = []
 
3745
        def record_post_transform(tree, tt):
 
3746
            calls.append((tree, tt))
 
3747
        MutableTree.hooks.install_named_hook('post_transform',
 
3748
            record_post_transform, "Post transform")
 
3749
        transform, root = self.get_transform()
 
3750
        old_root_id = transform.tree_file_id(root)
 
3751
        transform.apply()
 
3752
        self.assertEqual(old_root_id, self.wt.get_root_id())
 
3753
        self.assertEquals([(self.wt, transform)], calls)