~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-20 13:20:02 UTC
  • mto: This revision was merged to the branch mainline in revision 6395.
  • Revision ID: jelmer@canonical.com-20111220132002-55l9z4dg0qet0yvu
update news.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3246
3246
 
3247
3247
class TestMergeHooks(TestCaseWithTransport):
3248
3248
 
3249
 
    def setUp(self):
3250
 
        super(TestMergeHooks, self).setUp()
3251
 
        self.tree_a = self.make_branch_and_tree('tree_a')
 
3249
    def setup_trees_to_merge(self):
 
3250
        tree_a = self.make_branch_and_tree('tree_a')
3252
3251
        self.build_tree_contents([('tree_a/file', 'content_1')])
3253
 
        self.tree_a.add('file', 'file-id')
3254
 
        self.tree_a.commit('added file')
 
3252
        tree_a.add('file', 'file-id')
 
3253
        tree_a.commit('added file')
3255
3254
 
3256
 
        self.tree_b = self.tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
3255
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
3257
3256
        self.build_tree_contents([('tree_b/file', 'content_2')])
3258
 
        self.tree_b.commit('modify file')
 
3257
        tree_b.commit('modify file')
 
3258
        return tree_a, tree_b
3259
3259
 
3260
 
    def test_pre_merge_hook_inject_different_tree(self):
3261
 
        tree_c = self.tree_b.bzrdir.sprout('tree_c').open_workingtree()
 
3260
    def test_pre_merge(self):
 
3261
        tree_a, tree_b = self.setup_trees_to_merge()
 
3262
        tree_c = tree_b.bzrdir.sprout('tree_c').open_workingtree()
3262
3263
        self.build_tree_contents([('tree_c/file', 'content_3')])
3263
3264
        tree_c.commit("more content")
3264
3265
        calls = []
3268
3269
            calls.append(merger)
3269
3270
        _mod_merge.Merger.hooks.install_named_hook('pre_merge',
3270
3271
                                                   factory, 'test factory')
3271
 
        self.tree_a.merge_from_branch(self.tree_b.branch)
 
3272
        tree_a.merge_from_branch(tree_b.branch)
3272
3273
 
3273
3274
        self.assertFileEqual("content_3", 'tree_a/file')
 
3275
 
3274
3276
        self.assertLength(1, calls)
3275
3277
 
3276
 
    def test_post_merge_hook_called(self):
 
3278
    def test_post_merge(self):
3277
3279
        calls = []
3278
3280
        def factory(merger):
3279
3281
            self.assertIsInstance(merger, _mod_merge.Merge3Merger)
3281
3283
        _mod_merge.Merger.hooks.install_named_hook('post_merge',
3282
3284
                                                   factory, 'test factory')
3283
3285
 
3284
 
        self.tree_a.merge_from_branch(self.tree_b.branch)
 
3286
        tree_a, tree_b = self.setup_trees_to_merge()
 
3287
        tree_a.merge_from_branch(tree_b.branch)
3285
3288
 
3286
3289
        self.assertFileEqual("content_2", 'tree_a/file')
 
3290
 
3287
3291
        self.assertLength(1, calls)