~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-29 11:48:10 UTC
  • mfrom: (4988.1.2 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100129114810-pizbq0hfw5wctdaq
(jam) Merge 2.1.0rc2 into bzr.dev, including per-file merge hook

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
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,
 
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
            name_prefix = "foo"
 
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
 
2855
            return 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)