1
# Copyright (C) 2011 Canonical Ltd
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.
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.
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
17
from __future__ import absolute_import
19
__doc__ = """Merge hook for ``.po`` files.
21
To enable this plugin, add a section to your branch.conf or location.conf
25
po_merge.pot_dirs = po,doc/po4a/po
27
The ``po_merge.pot_dirs`` config option takes a list of directories that can
28
contain ``.po`` files, separated by commas (if several directories are
29
needed). Each directory should contain a single ``.pot`` file.
31
The ``po_merge.command`` is the command whose output is used as the result of
32
the merge. It defaults to::
34
msgmerge -N "{other}" "{pot_file}" -C "{this}" -o "{result}"
38
* ``this`` is the ``.po`` file content before the merge in the current branch,
39
* ``other`` is the ``.po`` file content in the branch merged from,
40
* ``pot_file`` is the path to the ``.pot`` file corresponding to the ``.po``
43
If conflicts occur in a ``.pot`` file during a given merge, the ``.po`` files
44
will use the ``.pot`` file present in tree before the merge. If this doesn't
45
suit your needs, you should can disable the plugin during the merge with::
47
bzr merge <usual merge args> -Opo_merge.po_dirs=
49
This will allow you to resolve the conflicts in the ``.pot`` file and then
50
merge the ``.po`` files again with::
52
bzr remerge po/*.po doc/po4a/po/*.po
58
# Since we are a built-in plugin we share the bzrlib version
61
from bzrlib.hooks import install_lazy_named_hook
64
def register_lazy_option(key, member):
65
config.option_registry.register_lazy(
66
key, 'bzrlib.plugins.po_merge.po_merge', member)
69
register_lazy_option('po_merge.command', 'command_option')
70
register_lazy_option('po_merge.po_dirs', 'po_dirs_option')
71
register_lazy_option('po_merge.po_glob', 'po_glob_option')
72
register_lazy_option('po_merge.pot_glob', 'pot_glob_option')
75
def po_merge_hook(merger):
76
"""Merger.merge_file_content hook for po files."""
77
from bzrlib.plugins.po_merge.po_merge import PoMerger
78
return PoMerger(merger)
81
install_lazy_named_hook("bzrlib.merge", "Merger.hooks", "merge_file_content",
82
po_merge_hook, ".po file merge")
85
def load_tests(basic_tests, module, loader):
89
basic_tests.addTest(loader.loadTestsFromModuleNames(
90
["%s.%s" % (__name__, tmn) for tmn in testmod_names]))