~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-26 10:49:57 UTC
  • mfrom: (4987.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100126104957-dmtqnc0pckuruyla
(vila,
        jam) Implement TestCase.overrideAttr to simplify tests setUp/cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 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 (
37
 
    TestCaseWithMemoryTransport,
38
 
    TestCaseWithTransport,
39
 
    test_merge_core,
40
 
    )
 
36
from bzrlib.tests import TestCaseWithTransport, TestCaseWithMemoryTransport
41
37
from bzrlib.workingtree import WorkingTree
42
38
 
43
39
 
2837
2833
            'bval', ['lca1val', 'lca2val', 'lca2val'], 'oval', 'tval')
2838
2834
        self.assertLCAMultiWay('conflict',
2839
2835
            '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)