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):
3249
def setup_trees_to_merge(self):
3250
tree_a = self.make_branch_and_tree('tree_a')
3251
self.build_tree_contents([('tree_a/file', 'content_1')])
3252
tree_a.add('file', 'file-id')
3253
tree_a.commit('added file')
3255
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
3256
self.build_tree_contents([('tree_b/another-file', 'content_2')])
3257
tree_b.add('another-file', 'another-file-id')
3258
tree_b.commit('add another file')
3259
return tree_a, tree_b
3261
def test_pre_merge(self):
3263
def factory(pre_merge_args):
3264
calls.append(pre_merge_args)
3265
_mod_merge.Merger.hooks.install_named_hook('pre_merge',
3266
factory, 'test factory')
3267
tree_a, tree_b = self.setup_trees_to_merge()
3268
tree_a.merge_from_branch(tree_b.branch)
3270
self.assertLength(1, calls)
3272
def test_post_merge(self):
3274
def factory(post_merge_args):
3275
self.assertIsInstance(post_merge_args, _mod_merge.Merge3Merger)
3276
calls.append(post_merge_args)
3277
_mod_merge.Merger.hooks.install_named_hook('post_merge',
3278
factory, 'test factory')
3280
tree_a, tree_b = self.setup_trees_to_merge()
3281
tree_a.merge_from_branch(tree_b.branch)
3283
self.assertLength(1, calls)