1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
1
# Copyright (C) 2005-2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
33
33
from bzrlib.errors import UnrelatedBranches, NoCommits
34
34
from bzrlib.merge import transform_tree, merge_inner, _PlanMerge
35
35
from bzrlib.osutils import pathjoin, file_kind
36
from bzrlib.tests import TestCaseWithTransport, TestCaseWithMemoryTransport
36
from bzrlib.tests import (
37
TestCaseWithMemoryTransport,
38
TestCaseWithTransport,
37
41
from bzrlib.workingtree import WorkingTree
2833
2837
'bval', ['lca1val', 'lca2val', 'lca2val'], 'oval', 'tval')
2834
2838
self.assertLCAMultiWay('conflict',
2835
2839
'bval', ['lca1val', 'lca2val', 'lca3val'], 'oval', 'tval')
2842
class TestConfigurableFileMerger(tests.TestCaseWithTransport):
2844
def test_affected_files_cached(self):
2845
"""Ensures that the config variable is cached"""
2846
class SimplePlan(_mod_merge.ConfigurableFileMerger):
2848
default_files = ["my default"]
2849
def merge_text(self, params):
2850
return ('not applicable', None)
2851
def factory(merger):
2852
result = SimplePlan(merger)
2853
self.assertEqual(None, result.affected_files)
2854
self.merger = result
2856
_mod_merge.Merger.hooks.install_named_hook('merge_file_content',
2857
factory, 'test factory')
2858
builder = test_merge_core.MergeBuilder(self.test_base_dir)
2859
self.addCleanup(builder.cleanup)
2860
builder.add_file('NEWS', builder.tree_root, 'name1', 'text1', True)
2861
builder.change_contents('NEWS', other='text4', this='text3')
2862
conflicts = builder.merge()
2863
# The hook should set the variable
2864
self.assertEqual(["my default"], self.merger.affected_files)