3242
3242
# The dest tree is unmodified.
3243
3243
self.assertEqual(['r1-dest'], dest_wt.get_parent_ids())
3244
3244
self.assertTreeEntriesEqual([('', 'dest-root-id')], dest_wt)
3247
class TestMergeHooks(TestCaseWithTransport):
3250
super(TestMergeHooks, self).setUp()
3251
self.tree_a = self.make_branch_and_tree('tree_a')
3252
self.build_tree_contents([('tree_a/file', 'content_1')])
3253
self.tree_a.add('file', 'file-id')
3254
self.tree_a.commit('added file')
3256
self.tree_b = self.tree_a.bzrdir.sprout('tree_b').open_workingtree()
3257
self.build_tree_contents([('tree_b/file', 'content_2')])
3258
self.tree_b.commit('modify file')
3260
def test_pre_merge_hook_inject_different_tree(self):
3261
tree_c = self.tree_b.bzrdir.sprout('tree_c').open_workingtree()
3262
self.build_tree_contents([('tree_c/file', 'content_3')])
3263
tree_c.commit("more content")
3265
def factory(merger):
3266
self.assertIsInstance(merger, _mod_merge.Merge3Merger)
3267
merger.other_tree = tree_c
3268
calls.append(merger)
3269
_mod_merge.Merger.hooks.install_named_hook('pre_merge',
3270
factory, 'test factory')
3271
self.tree_a.merge_from_branch(self.tree_b.branch)
3273
self.assertFileEqual("content_3", 'tree_a/file')
3274
self.assertLength(1, calls)
3276
def test_post_merge_hook_called(self):
3278
def factory(merger):
3279
self.assertIsInstance(merger, _mod_merge.Merge3Merger)
3280
calls.append(merger)
3281
_mod_merge.Merger.hooks.install_named_hook('post_merge',
3282
factory, 'test factory')
3284
self.tree_a.merge_from_branch(self.tree_b.branch)
3286
self.assertFileEqual("content_2", 'tree_a/file')
3287
self.assertLength(1, calls)