2
# Copyright (C) 2011 by Canonical Ltd
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
from bzrlib.tests import (
29
from bzrlib.plugins import po_merge
31
class BlackboxTestPoMerger(script.TestCaseWithTransportAndScript):
33
_test_needs_features = [features.msgmerge_feature]
36
super(BlackboxTestPoMerger, self).setUp()
37
self.builder = make_adduser_branch(self, 'adduser')
38
# We need to install our hook as the test framework cleared it as part
39
# of the initialization
40
merge.Merger.hooks.install_named_hook(
41
"merge_file_content", po_merge.po_merge_hook, ".po file merge")
43
def test_merge_with_hook_gives_unexpected_results(self):
44
# Since the conflicts in .pot are not seen *during* the merge, the .po
45
# merge triggers the hook and creates no conflicts for fr.po. But the
46
# .pot used is the one present in the tree *before* the merge.
48
$ bzr branch adduser -rrevid:this work
49
2>Branched 2 revisions.
51
$ bzr merge ../adduser -rrevid:other
54
2>Text conflict in po/adduser.pot
55
2>1 conflicts encountered.
58
def test_called_on_remerge(self):
59
# Merge with no config for the hook to create the conflicts
61
$ bzr branch adduser -rrevid:this work
62
2>Branched 2 revisions.
64
# set po_dirs to an empty list
65
$ bzr merge ../adduser -rrevid:other -Opo_merge.po_dirs=
68
2>Text conflict in po/adduser.pot
69
2>Text conflict in po/fr.po
70
2>2 conflicts encountered.
72
# Fix the conflicts in the .pot file
73
with open('po/adduser.pot', 'w') as f:
74
f.write(_Adduser['resolved_pot'])
75
# Tell bzr the conflict is resolved
77
$ bzr resolve po/adduser.pot
78
2>1 conflict resolved, 1 remaining
79
# Use remerge to trigger the hook, we use the default config options here
81
2>All changes applied successfully.
82
# There should be no conflicts anymore
87
def make_adduser_branch(test, relpath):
88
"""Helper for po_merge blackbox tests.
90
This creates a branch containing the needed base revisions so tests can
91
attempt merges and conflict resolutions.
93
builder = test.make_branch_builder(relpath)
94
builder.start_series()
95
builder.build_snapshot('base', None,
96
[('add', ('', 'root-id', 'directory', '')),
98
('add', ('po', 'dir-id', 'directory', None),),
99
('add', ('po/adduser.pot', 'pot-id', 'file',
100
_Adduser['base_pot'])),
101
('add', ('po/fr.po', 'po-id', 'file',
102
_Adduser['base_po'])),
105
builder.build_snapshot('other', ['base'],
106
[('modify', ('pot-id',
107
_Adduser['other_pot'])),
109
_Adduser['other_po'])),
112
builder.build_snapshot('this', ['base'],
113
[('modify', ('pot-id', _Adduser['this_pot'])),
114
('modify', ('po-id', _Adduser['this_po'])),
116
# builder.get_branch() tip is now 'this'
117
builder.finish_series()
121
class TestAdduserBranch(script.TestCaseWithTransportAndScript):
122
"""Sanity checks on the adduser branch content."""
125
super(TestAdduserBranch, self).setUp()
126
self.builder = make_adduser_branch(self, 'adduser')
128
def assertAdduserBranchContent(self, revid):
129
env = dict(revid=revid, branch_name=revid)
131
$ bzr branch adduser -rrevid:%(revid)s %(branch_name)s
132
""" % env, null_output_matches_anything=True)
133
self.assertFileEqual(_Adduser['%(revid)s_pot' % env],
134
'%(branch_name)s/po/adduser.pot' % env)
135
self.assertFileEqual(_Adduser['%(revid)s_po' % env],
136
'%(branch_name)s/po/fr.po' % env )
139
self.assertAdduserBranchContent('base')
142
self.assertAdduserBranchContent('this')
144
def test_other(self):
145
self.assertAdduserBranchContent('other')
148
# Real content from the adduser package so we don't have to guess about format
149
# details. This is declared at the end of the file to avoid cluttering the
150
# beginning of the file.
153
base_pot = r"""# SOME DESCRIPTIVE TITLE.
154
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
155
# This file is distributed under the same license as the PACKAGE package.
156
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
161
"Project-Id-Version: PACKAGE VERSION\n"
162
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
163
"POT-Creation-Date: 2007-01-17 21:50+0100\n"
164
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
165
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
166
"Language-Team: LANGUAGE <LL@example.com>\n"
167
"MIME-Version: 1.0\n"
168
"Content-Type: text/plain; charset=CHARSET\n"
169
"Content-Transfer-Encoding: 8bit\n"
171
#. everyone can issue "--help" and "--version", but only root can go on
173
msgid "Only root may add a user or group to the system.\n"
177
msgid "Warning: The home dir you specified already exists.\n"
181
this_pot = r"""# SOME DESCRIPTIVE TITLE.
182
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
183
# This file is distributed under the same license as the PACKAGE package.
184
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
189
"Project-Id-Version: PACKAGE VERSION\n"
190
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
191
"POT-Creation-Date: 2011-01-06 21:06+0000\n"
192
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
193
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
194
"Language-Team: LANGUAGE <LL@example.com>\n"
196
"MIME-Version: 1.0\n"
197
"Content-Type: text/plain; charset=CHARSET\n"
198
"Content-Transfer-Encoding: 8bit\n"
200
#. everyone can issue "--help" and "--version", but only root can go on
202
msgid "Only root may add a user or group to the system.\n"
207
msgid "Warning: The home dir %s you specified already exists.\n"
212
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
216
other_pot = r"""# SOME DESCRIPTIVE TITLE.
217
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
218
# This file is distributed under the same license as the PACKAGE package.
219
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
224
"Project-Id-Version: PACKAGE VERSION\n"
225
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
226
"POT-Creation-Date: 2010-11-21 17:13-0400\n"
227
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
228
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
229
"Language-Team: LANGUAGE <LL@example.com>\n"
231
"MIME-Version: 1.0\n"
232
"Content-Type: text/plain; charset=CHARSET\n"
233
"Content-Transfer-Encoding: 8bit\n"
235
#. everyone can issue "--help" and "--version", but only root can go on
237
msgid "Only root may add a user or group to the system.\n"
242
msgid "Warning: The home dir %s you specified already exists.\n"
247
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
251
resolved_pot = r"""# SOME DESCRIPTIVE TITLE.
252
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
253
# This file is distributed under the same license as the PACKAGE package.
254
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
259
"Project-Id-Version: PACKAGE VERSION\n"
260
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
261
"POT-Creation-Date: 2011-10-19 12:50-0700\n"
262
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
263
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
264
"Language-Team: LANGUAGE <LL@example.com>\n"
266
"MIME-Version: 1.0\n"
267
"Content-Type: text/plain; charset=CHARSET\n"
268
"Content-Transfer-Encoding: 8bit\n"
270
#. everyone can issue "--help" and "--version", but only root can go on
272
msgid "Only root may add a user or group to the system.\n"
277
msgid "Warning: The home dir %s you specified already exists.\n"
282
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
286
base_po = r"""# adduser's manpages translation to French
287
# Copyright (C) 2004 Software in the Public Interest
288
# This file is distributed under the same license as the adduser package
291
# Jean-Baka Domelevo Entfellner <domelevo@example.com>, 2009.
295
"Project-Id-Version: adduser 3.111\n"
296
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
297
"POT-Creation-Date: 2007-01-17 21:50+0100\n"
298
"PO-Revision-Date: 2010-01-21 10:36+0100\n"
299
"Last-Translator: Jean-Baka Domelevo Entfellner <domelevo@example.com>\n"
300
"Language-Team: Debian French Team <debian-l10n-french@example.com>\n"
302
"MIME-Version: 1.0\n"
303
"Content-Type: text/plain; charset=UTF-8\n"
304
"Content-Transfer-Encoding: 8bit\n"
305
"X-Poedit-Language: French\n"
306
"X-Poedit-Country: FRANCE\n"
309
#. everyone can issue "--help" and "--version", but only root can go on
311
msgid "Only root may add a user or group to the system.\n"
313
"Seul le superutilisateur est autorisé à ajouter un utilisateur ou un groupe "
317
msgid "Warning: The home dir you specified already exists.\n"
319
"Attention ! Le répertoire personnel que vous avez indiqué existe déjà.\n"
322
this_po = r"""# adduser's manpages translation to French
323
# Copyright (C) 2004 Software in the Public Interest
324
# This file is distributed under the same license as the adduser package
327
# Jean-Baka Domelevo Entfellner <domelevo@example.com>, 2009.
331
"Project-Id-Version: adduser 3.111\n"
332
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
333
"POT-Creation-Date: 2010-10-12 15:48+0200\n"
334
"PO-Revision-Date: 2010-01-21 10:36+0100\n"
335
"Last-Translator: Jean-Baka Domelevo Entfellner <domelevo@example.com>\n"
336
"Language-Team: Debian French Team <debian-l10n-french@example.com>\n"
338
"MIME-Version: 1.0\n"
339
"Content-Type: text/plain; charset=UTF-8\n"
340
"Content-Transfer-Encoding: 8bit\n"
341
"X-Poedit-Language: French\n"
342
"X-Poedit-Country: FRANCE\n"
345
#. everyone can issue "--help" and "--version", but only root can go on
347
msgid "Only root may add a user or group to the system.\n"
349
"Seul le superutilisateur est autorisé à ajouter un utilisateur ou un groupe "
353
#, fuzzy, perl-format
354
msgid "Warning: The home dir %s you specified already exists.\n"
356
"Attention ! Le répertoire personnel que vous avez indiqué existe déjà.\n"
359
#, fuzzy, perl-format
360
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
362
"Attention ! Le répertoire personnel que vous avez indiqué existe déjà.\n"
365
other_po = r"""# adduser's manpages translation to French
366
# Copyright (C) 2004 Software in the Public Interest
367
# This file is distributed under the same license as the adduser package
370
# Jean-Baka Domelevo Entfellner <domelevo@example.com>, 2009, 2010.
374
"Project-Id-Version: adduser 3.112+nmu2\n"
375
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
376
"POT-Creation-Date: 2010-11-21 17:13-0400\n"
377
"PO-Revision-Date: 2010-11-10 11:08+0100\n"
378
"Last-Translator: Jean-Baka Domelevo-Entfellner <domelevo@example.com>\n"
379
"Language-Team: Debian French Team <debian-l10n-french@example.com>\n"
381
"MIME-Version: 1.0\n"
382
"Content-Type: text/plain; charset=UTF-8\n"
383
"Content-Transfer-Encoding: 8bit\n"
384
"X-Poedit-Country: FRANCE\n"
387
#. everyone can issue "--help" and "--version", but only root can go on
389
msgid "Only root may add a user or group to the system.\n"
391
"Seul le superutilisateur est autorisé à ajouter un utilisateur ou un groupe "
396
msgid "Warning: The home dir %s you specified already exists.\n"
398
"Attention ! Le répertoire personnel que vous avez indiqué (%s) existe déjà.\n"
402
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
404
"Attention ! Impossible d'accéder au répertoire personnel que vous avez "
405
"indiqué (%s) : %s.\n"
408
resolved_po = r"""# adduser's manpages translation to French
409
# Copyright (C) 2004 Software in the Public Interest
410
# This file is distributed under the same license as the adduser package
413
# Jean-Baka Domelevo Entfellner <domelevo@example.com>, 2009, 2010.
417
"Project-Id-Version: adduser 3.112+nmu2\n"
418
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
419
"POT-Creation-Date: 2011-10-19 12:50-0700\n"
420
"PO-Revision-Date: 2010-11-10 11:08+0100\n"
421
"Last-Translator: Jean-Baka Domelevo-Entfellner <domelevo@example.com>\n"
422
"Language-Team: Debian French Team <debian-l10n-french@example.com>\n"
424
"MIME-Version: 1.0\n"
425
"Content-Type: text/plain; charset=UTF-8\n"
426
"Content-Transfer-Encoding: 8bit\n"
427
"X-Poedit-Country: FRANCE\n"
430
#. everyone can issue "--help" and "--version", but only root can go on
432
msgid "Only root may add a user or group to the system.\n"
434
"Seul le superutilisateur est autorisé à ajouter un utilisateur ou un groupe "
439
msgid "Warning: The home dir %s you specified already exists.\n"
441
"Attention ! Le répertoire personnel que vous avez indiqué (%s) existe déjà.\n"
445
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
447
"Attention ! Impossible d'accéder au répertoire personnel que vous avez "
448
"indiqué (%s) : %s.\n"