~bzr-pqm/bzr/bzr.dev

4869.4.1 by Andrew Bennetts
Add plugin for merging bzr's NEWS file to contrib/.
1
# Copyright (C) 2010 Canonical Ltd
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
5131.2.2 by Martin
Catch a couple of missed plugin module docstrings, note need for assignment to __doc__ in developer documentation and NEWS
17
__doc__ = """Merge hook for bzr's NEWS file.
4869.4.1 by Andrew Bennetts
Add plugin for merging bzr's NEWS file to contrib/.
18
4869.3.27 by Andrew Bennetts
Move news_merge plugin from contrib to bzrlib/plugins, change it to be enabled via a 'news_merge_files' config option, move more code out of the __init__ to minimise overhead, and add lots of docstrings, add NEWS entry.
19
To enable this plugin, add a section to your branch.conf or location.conf
20
like::
21
22
    [/home/user/code/bzr]
23
    news_merge_files = NEWS
24
25
The news_merge_files config option takes a list of file paths, separated by
26
commas.
27
28
Limitations:
29
30
* if there's a conflict in more than just bullet points, this doesn't yet know
31
  how to resolve that, so bzr will fallback to the default line-based merge.
4869.4.1 by Andrew Bennetts
Add plugin for merging bzr's NEWS file to contrib/.
32
"""
33
4869.3.34 by Vincent Ladeuil
Finish the patch based on reviews.
34
# Since we are a built-in plugin we share the bzrlib version
35
from bzrlib import version_info
36
4869.3.27 by Andrew Bennetts
Move news_merge plugin from contrib to bzrlib/plugins, change it to be enabled via a 'news_merge_files' config option, move more code out of the __init__ to minimise overhead, and add lots of docstrings, add NEWS entry.
37
# Put most of the code in a separate module that we lazy-import to keep the
38
# overhead of this plugin as minimal as possible.
4869.3.25 by Andrew Bennetts
Use 2.4 syntax and lazy_import in news_merge plugin.
39
from bzrlib.lazy_import import lazy_import
40
lazy_import(globals(), """
4797.5.1 by Robert Collins
Support state on per-file merging to permit more efficient use of configuration data.
41
from bzrlib.plugins.news_merge import news_merge as _mod_news_merge
4869.3.25 by Andrew Bennetts
Use 2.4 syntax and lazy_import in news_merge plugin.
42
""")
4869.4.1 by Andrew Bennetts
Add plugin for merging bzr's NEWS file to contrib/.
43
44
from bzrlib.merge import Merger
45
46
4797.5.1 by Robert Collins
Support state on per-file merging to permit more efficient use of configuration data.
47
def news_merge_hook(merger):
48
    """Merger.merge_file_content hook for bzr-format NEWS files."""
49
    return _mod_news_merge.NewsMerger(merger)
50
4869.4.1 by Andrew Bennetts
Add plugin for merging bzr's NEWS file to contrib/.
51
4869.3.34 by Vincent Ladeuil
Finish the patch based on reviews.
52
def install_hook():
53
    Merger.hooks.install_named_hook(
54
        'merge_file_content', news_merge_hook, 'NEWS file merge')
55
install_hook()
56
57
58
def load_tests(basic_tests, module, loader):
59
    testmod_names = [
60
        'tests',
61
        ]
62
    basic_tests.addTest(loader.loadTestsFromModuleNames(
63
            ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
64
    return basic_tests
4869.4.1 by Andrew Bennetts
Add plugin for merging bzr's NEWS file to contrib/.
65