~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/news_merge/__init__.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-20 16:05:28 UTC
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: v.ladeuil+lp@free.fr-20100120160528-5yo3fbggdp07eovc
Finish the patch based on reviews.

* bzrlib/tests/per_merger.py:
Fix line too long and spurious spaces.

* bzrlib/plugins/news_merge/tests/test_news_merge.py:
(TestFilenameMatchesConfig): Ensure that the params get updated.

* bzrlib/plugins/news_merge/__init__.py:
(filename_matches_config): Save the relevant config variable in
the hook params.
(install_hook): Wrap the hook installation so we can reuse it for
tests.

* bzrlib/plugins/news_merge/README: 
Update the instructions by pointing to the plugin help.

* bzrlib/merge.py:
(MergeHookParams): Delete spurious spaces.

* bzrlib/decorators.py:
(use_pretty_decorators): Mention that we get clearance to copy
launchpad code here (since canonical has copyrights on both code
bases).

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
  how to resolve that, so bzr will fallback to the default line-based merge.
33
33
"""
34
34
 
 
35
# Since we are a built-in plugin we share the bzrlib version
 
36
from bzrlib import version_info
 
37
 
35
38
# Put most of the code in a separate module that we lazy-import to keep the
36
39
# overhead of this plugin as minimal as possible.
37
40
from bzrlib.lazy_import import lazy_import
59
62
 
60
63
 
61
64
def filename_matches_config(params):
62
 
    config = params.merger.this_branch.get_config()
63
 
    affected_files = config.get_user_option_as_list('news_merge_files')
 
65
    affected_files = getattr(params, '_news_merge_affected_files', None)
 
66
    if affected_files is None:
 
67
        config = params.merger.this_tree.branch.get_config()
 
68
        # Until bzr provides a better policy for caching the config, we just
 
69
        # add the part we're interested in to the params to avoid reading the
 
70
        # config files repeatedly (bazaar.conf, location.conf, branch.conf).
 
71
        affected_files = config.get_user_option_as_list('news_merge_files')
 
72
        if affected_files is None:
 
73
            # If nothing was specified in the config, we have nothing to do,
 
74
            # but we use None in the params to start the caching.
 
75
            affected_files = []
 
76
        params._news_merge_affected_files = affected_files
64
77
    if affected_files:
65
78
        filename = params.merger.this_tree.id2path(params.file_id)
66
79
        if filename in affected_files:
67
80
            return True
68
81
    return False
69
82
 
70
 
 
71
 
Merger.hooks.install_named_hook(
72
 
    'merge_file_content', news_merge_hook, 'NEWS file merge')
 
83
def install_hook():
 
84
    Merger.hooks.install_named_hook(
 
85
        'merge_file_content', news_merge_hook, 'NEWS file merge')
 
86
install_hook()
 
87
 
 
88
 
 
89
def load_tests(basic_tests, module, loader):
 
90
    testmod_names = [
 
91
        'tests',
 
92
        ]
 
93
    basic_tests.addTest(loader.loadTestsFromModuleNames(
 
94
            ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
 
95
    return basic_tests
73
96