~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Robert Collins
  • Date: 2010-01-28 18:01:03 UTC
  • mto: (4797.2.5 2.1)
  • mto: This revision was merged to the branch mainline in revision 4989.
  • Revision ID: robertc@robertcollins.net-20100128180103-kj106kj55vsbqxu1
Refactor NewsMerger into a reusable base class merge.ConfigurableFileMerger.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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,
 
39
    test_merge_core,
 
40
    )
37
41
from bzrlib.workingtree import WorkingTree
38
42
 
39
43
 
2833
2837
            'bval', ['lca1val', 'lca2val', 'lca2val'], 'oval', 'tval')
2834
2838
        self.assertLCAMultiWay('conflict',
2835
2839
            'bval', ['lca1val', 'lca2val', 'lca3val'], 'oval', 'tval')
 
2840
 
 
2841
 
 
2842
class TestConfigurableFileMerger(tests.TestCaseWithTransport):
 
2843
 
 
2844
    def test_affected_files_cached(self):
 
2845
        """Ensures that the config variable is cached"""
 
2846
        class SimplePlan(_mod_merge.ConfigurableFileMerger):
 
2847
            def merge_text(self, params):
 
2848
                return ('not applicable', None)
 
2849
        def factory(merger):
 
2850
            result = SimplePlan(merger, "foo", ["my default"])
 
2851
            self.assertEqual(None, result.affected_files)
 
2852
            self.merger = result
 
2853
            return result
 
2854
        _mod_merge.Merger.hooks.install_named_hook('merge_file_content',
 
2855
            factory, 'test factory')
 
2856
        builder = test_merge_core.MergeBuilder(self.test_base_dir)
 
2857
        self.addCleanup(builder.cleanup)
 
2858
        builder.add_file('NEWS', builder.tree_root, 'name1', 'text1', True)
 
2859
        builder.change_contents('NEWS', other='text4', this='text3')
 
2860
        conflicts = builder.merge()
 
2861
        # The hook should set the variable
 
2862
        self.assertEqual(["my default"], self.merger.affected_files)