bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
1 |
# Copyright (C) 2011 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 |
||
17 |
__doc__ = """Merge hook for ``.po`` files. |
|
18 |
||
19 |
To enable this plugin, add a section to your branch.conf or location.conf
|
|
20 |
like::
|
|
21 |
||
22 |
[/home/user/code/bzr]
|
|
|
6282.3.5
by Vincent Ladeuil
Update the doc. |
23 |
po_merge.pot_dirs = po,doc/po4a/po
|
24 |
||
25 |
The ``po_merge.pot_dirs`` config option takes a list of directories that can
|
|
26 |
contain ``.po`` files, separated by commas (if several directories are
|
|
27 |
needed). Each directory should contain a single ``.pot`` file.
|
|
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
28 |
|
29 |
The ``po_merge.command`` is the command whose output is used as the result of
|
|
30 |
the merge. It defaults to::
|
|
31 |
||
32 |
msgmerge -N "{other}" "{pot_file}" -C "{this}" -o "{result}" |
|
33 |
||
34 |
where:
|
|
35 |
||
36 |
* ``this`` is the ``.po`` file content before the merge in the current branch,
|
|
37 |
* ``other`` is the ``.po`` file content in the branch merged from,
|
|
38 |
* ``pot_file`` is the path to the ``.pot`` file corresponding to the ``.po``
|
|
39 |
file being merged.
|
|
40 |
||
|
6282.3.5
by Vincent Ladeuil
Update the doc. |
41 |
If conflicts occur in a ``.pot`` file during a given merge, the ``.po`` files
|
42 |
will use the ``.pot`` file present in tree before the merge. If this doesn't
|
|
43 |
suit your needs, you should can disable the plugin during the merge with::
|
|
44 |
||
45 |
bzr merge <usual merge args> -Opo_merge.po_dirs=
|
|
46 |
||
47 |
This will allow you to resolve the conflicts in the ``.pot`` file and then
|
|
48 |
merge the ``.po`` files again with::
|
|
49 |
||
50 |
bzr remerge po/*.po doc/po4a/po/*.po
|
|
51 |
||
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
52 |
"""
|
53 |
||
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
54 |
from ... import ( |
|
6282.3.13
by Vincent Ladeuil
Register the options earlier so 'bzr help po_merge.pot_dirs' can be used. |
55 |
config, |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
56 |
# Since we are a built-in plugin we share the breezy version
|
|
7143.11.1
by Jelmer Vernooij
Remove some unused imports. |
57 |
version_info, # noqa: F401 |
|
6282.3.13
by Vincent Ladeuil
Register the options earlier so 'bzr help po_merge.pot_dirs' can be used. |
58 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
59 |
from ...hooks import install_lazy_named_hook |
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
60 |
|
61 |
||
|
6282.3.14
by Vincent Ladeuil
Use lazy registration for plugin options to set a good example. |
62 |
def register_lazy_option(key, member): |
63 |
config.option_registry.register_lazy( |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
64 |
key, 'breezy.plugins.po_merge.po_merge', member) |
|
6282.3.14
by Vincent Ladeuil
Use lazy registration for plugin options to set a good example. |
65 |
|
66 |
||
67 |
register_lazy_option('po_merge.command', 'command_option') |
|
68 |
register_lazy_option('po_merge.po_dirs', 'po_dirs_option') |
|
69 |
register_lazy_option('po_merge.po_glob', 'po_glob_option') |
|
70 |
register_lazy_option('po_merge.pot_glob', 'pot_glob_option') |
|
|
6282.3.13
by Vincent Ladeuil
Register the options earlier so 'bzr help po_merge.pot_dirs' can be used. |
71 |
|
72 |
||
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
73 |
def po_merge_hook(merger): |
|
6391.1.1
by Benjamin Peterson
fix copy and paste error |
74 |
"""Merger.merge_file_content hook for po files.""" |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
75 |
from .po_merge import PoMerger |
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
76 |
return PoMerger(merger) |
77 |
||
78 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
79 |
install_lazy_named_hook("breezy.merge", "Merger.hooks", "merge_file_content", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
80 |
po_merge_hook, ".po file merge") |
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
81 |
|
82 |
||
|
6625.1.5
by Martin
Drop custom load_tests implementation and use unittest signature |
83 |
def load_tests(loader, basic_tests, pattern): |
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
84 |
testmod_names = [ |
85 |
'tests', |
|
86 |
]
|
|
87 |
basic_tests.addTest(loader.loadTestsFromModuleNames( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
88 |
["%s.%s" % (__name__, tmn) for tmn in testmod_names])) |
|
6282.3.1
by Vincent Ladeuil
First cut at a working plugin to avoid conflicts in .po files by shelling out to msgmerge. |
89 |
return basic_tests |