/usr/lib/python2.7/dist-packages/bzrlib/plugins/po_merge/tests/test_po_merge.py is in python-bzrlib 2.7.0-2ubuntu3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | # -*- coding: utf-8
# Copyright (C) 2011 by Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import os
from bzrlib import (
merge,
tests,
)
from bzrlib.tests import (
features,
script,
)
from bzrlib.plugins import po_merge
class BlackboxTestPoMerger(script.TestCaseWithTransportAndScript):
_test_needs_features = [features.msgmerge_feature]
def setUp(self):
super(BlackboxTestPoMerger, self).setUp()
self.builder = make_adduser_branch(self, 'adduser')
# We need to install our hook as the test framework cleared it as part
# of the initialization
merge.Merger.hooks.install_named_hook(
"merge_file_content", po_merge.po_merge_hook, ".po file merge")
def test_merge_with_hook_gives_unexpected_results(self):
# Since the conflicts in .pot are not seen *during* the merge, the .po
# merge triggers the hook and creates no conflicts for fr.po. But the
# .pot used is the one present in the tree *before* the merge.
self.run_script("""\
$ bzr branch adduser -rrevid:this work
2>Branched 2 revisions.
$ cd work
$ bzr merge ../adduser -rrevid:other
2> M po/adduser.pot
2> M po/fr.po
2>Text conflict in po/adduser.pot
2>1 conflicts encountered.
""")
def test_called_on_remerge(self):
# Merge with no config for the hook to create the conflicts
self.run_script("""\
$ bzr branch adduser -rrevid:this work
2>Branched 2 revisions.
$ cd work
# set po_dirs to an empty list
$ bzr merge ../adduser -rrevid:other -Opo_merge.po_dirs=
2> M po/adduser.pot
2> M po/fr.po
2>Text conflict in po/adduser.pot
2>Text conflict in po/fr.po
2>2 conflicts encountered.
""")
# Fix the conflicts in the .pot file
with open('po/adduser.pot', 'w') as f:
f.write(_Adduser['resolved_pot'])
# Tell bzr the conflict is resolved
self.run_script("""\
$ bzr resolve po/adduser.pot
2>1 conflict resolved, 1 remaining
# Use remerge to trigger the hook, we use the default config options here
$ bzr remerge po/*.po
2>All changes applied successfully.
# There should be no conflicts anymore
$ bzr conflicts
""")
def make_adduser_branch(test, relpath):
"""Helper for po_merge blackbox tests.
This creates a branch containing the needed base revisions so tests can
attempt merges and conflict resolutions.
"""
builder = test.make_branch_builder(relpath)
builder.start_series()
builder.build_snapshot('base', None,
[('add', ('', 'root-id', 'directory', '')),
# Create empty files
('add', ('po', 'dir-id', 'directory', None),),
('add', ('po/adduser.pot', 'pot-id', 'file',
_Adduser['base_pot'])),
('add', ('po/fr.po', 'po-id', 'file',
_Adduser['base_po'])),
])
# The 'other' branch
builder.build_snapshot('other', ['base'],
[('modify', ('pot-id',
_Adduser['other_pot'])),
('modify', ('po-id',
_Adduser['other_po'])),
])
# The 'this' branch
builder.build_snapshot('this', ['base'],
[('modify', ('pot-id', _Adduser['this_pot'])),
('modify', ('po-id', _Adduser['this_po'])),
])
# builder.get_branch() tip is now 'this'
builder.finish_series()
return builder
class TestAdduserBranch(script.TestCaseWithTransportAndScript):
"""Sanity checks on the adduser branch content."""
def setUp(self):
super(TestAdduserBranch, self).setUp()
self.builder = make_adduser_branch(self, 'adduser')
def assertAdduserBranchContent(self, revid):
env = dict(revid=revid, branch_name=revid)
self.run_script("""\
$ bzr branch adduser -rrevid:%(revid)s %(branch_name)s
""" % env, null_output_matches_anything=True)
self.assertFileEqual(_Adduser['%(revid)s_pot' % env],
'%(branch_name)s/po/adduser.pot' % env)
self.assertFileEqual(_Adduser['%(revid)s_po' % env],
'%(branch_name)s/po/fr.po' % env )
def test_base(self):
self.assertAdduserBranchContent('base')
def test_this(self):
self.assertAdduserBranchContent('this')
def test_other(self):
self.assertAdduserBranchContent('other')
# Real content from the adduser package so we don't have to guess about format
# details. This is declared at the end of the file to avoid cluttering the
# beginning of the file.
_Adduser = dict(
base_pot = r"""# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
"POT-Creation-Date: 2007-01-17 21:50+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@example.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#. everyone can issue "--help" and "--version", but only root can go on
#: ../adduser:135
msgid "Only root may add a user or group to the system.\n"
msgstr ""
#: ../adduser:188
msgid "Warning: The home dir you specified already exists.\n"
msgstr ""
""",
this_pot = r"""# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
"POT-Creation-Date: 2011-01-06 21:06+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@example.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#. everyone can issue "--help" and "--version", but only root can go on
#: ../adduser:152
msgid "Only root may add a user or group to the system.\n"
msgstr ""
#: ../adduser:208
#, perl-format
msgid "Warning: The home dir %s you specified already exists.\n"
msgstr ""
#: ../adduser:210
#, perl-format
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
msgstr ""
""",
other_pot = r"""# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
"POT-Creation-Date: 2010-11-21 17:13-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@example.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#. everyone can issue "--help" and "--version", but only root can go on
#: ../adduser:150
msgid "Only root may add a user or group to the system.\n"
msgstr ""
#: ../adduser:206
#, perl-format
msgid "Warning: The home dir %s you specified already exists.\n"
msgstr ""
#: ../adduser:208
#, perl-format
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
msgstr ""
""",
resolved_pot = r"""# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
"POT-Creation-Date: 2011-10-19 12:50-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@example.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#. everyone can issue "--help" and "--version", but only root can go on
#: ../adduser:152
msgid "Only root may add a user or group to the system.\n"
msgstr ""
#: ../adduser:208
#, perl-format
msgid "Warning: The home dir %s you specified already exists.\n"
msgstr ""
#: ../adduser:210
#, perl-format
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
msgstr ""
""",
base_po = r"""# adduser's manpages translation to French
# Copyright (C) 2004 Software in the Public Interest
# This file is distributed under the same license as the adduser package
#
# Translators:
# Jean-Baka Domelevo Entfellner <domelevo@example.com>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: adduser 3.111\n"
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
"POT-Creation-Date: 2007-01-17 21:50+0100\n"
"PO-Revision-Date: 2010-01-21 10:36+0100\n"
"Last-Translator: Jean-Baka Domelevo Entfellner <domelevo@example.com>\n"
"Language-Team: Debian French Team <debian-l10n-french@example.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: French\n"
"X-Poedit-Country: FRANCE\n"
# type: Plain text
#. everyone can issue "--help" and "--version", but only root can go on
#: ../adduser:135
msgid "Only root may add a user or group to the system.\n"
msgstr ""
"Seul le superutilisateur est autorisé à ajouter un utilisateur ou un groupe "
"au système.\n"
#: ../adduser:188
msgid "Warning: The home dir you specified already exists.\n"
msgstr ""
"Attention ! Le répertoire personnel que vous avez indiqué existe déjà.\n"
""",
this_po = r"""# adduser's manpages translation to French
# Copyright (C) 2004 Software in the Public Interest
# This file is distributed under the same license as the adduser package
#
# Translators:
# Jean-Baka Domelevo Entfellner <domelevo@example.com>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: adduser 3.111\n"
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
"POT-Creation-Date: 2010-10-12 15:48+0200\n"
"PO-Revision-Date: 2010-01-21 10:36+0100\n"
"Last-Translator: Jean-Baka Domelevo Entfellner <domelevo@example.com>\n"
"Language-Team: Debian French Team <debian-l10n-french@example.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: French\n"
"X-Poedit-Country: FRANCE\n"
# type: Plain text
#. everyone can issue "--help" and "--version", but only root can go on
#: ../adduser:152
msgid "Only root may add a user or group to the system.\n"
msgstr ""
"Seul le superutilisateur est autorisé à ajouter un utilisateur ou un groupe "
"au système.\n"
#: ../adduser:208
#, fuzzy, perl-format
msgid "Warning: The home dir %s you specified already exists.\n"
msgstr ""
"Attention ! Le répertoire personnel que vous avez indiqué existe déjà.\n"
#: ../adduser:210
#, fuzzy, perl-format
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
msgstr ""
"Attention ! Le répertoire personnel que vous avez indiqué existe déjà.\n"
""",
other_po = r"""# adduser's manpages translation to French
# Copyright (C) 2004 Software in the Public Interest
# This file is distributed under the same license as the adduser package
#
# Translators:
# Jean-Baka Domelevo Entfellner <domelevo@example.com>, 2009, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: adduser 3.112+nmu2\n"
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
"POT-Creation-Date: 2010-11-21 17:13-0400\n"
"PO-Revision-Date: 2010-11-10 11:08+0100\n"
"Last-Translator: Jean-Baka Domelevo-Entfellner <domelevo@example.com>\n"
"Language-Team: Debian French Team <debian-l10n-french@example.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Country: FRANCE\n"
# type: Plain text
#. everyone can issue "--help" and "--version", but only root can go on
#: ../adduser:150
msgid "Only root may add a user or group to the system.\n"
msgstr ""
"Seul le superutilisateur est autorisé à ajouter un utilisateur ou un groupe "
"au système.\n"
#: ../adduser:206
#, perl-format
msgid "Warning: The home dir %s you specified already exists.\n"
msgstr ""
"Attention ! Le répertoire personnel que vous avez indiqué (%s) existe déjà.\n"
#: ../adduser:208
#, perl-format
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
msgstr ""
"Attention ! Impossible d'accéder au répertoire personnel que vous avez "
"indiqué (%s) : %s.\n"
""",
resolved_po = r"""# adduser's manpages translation to French
# Copyright (C) 2004 Software in the Public Interest
# This file is distributed under the same license as the adduser package
#
# Translators:
# Jean-Baka Domelevo Entfellner <domelevo@example.com>, 2009, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: adduser 3.112+nmu2\n"
"Report-Msgid-Bugs-To: adduser-devel@example.com\n"
"POT-Creation-Date: 2011-10-19 12:50-0700\n"
"PO-Revision-Date: 2010-11-10 11:08+0100\n"
"Last-Translator: Jean-Baka Domelevo-Entfellner <domelevo@example.com>\n"
"Language-Team: Debian French Team <debian-l10n-french@example.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Country: FRANCE\n"
# type: Plain text
#. everyone can issue "--help" and "--version", but only root can go on
#: ../adduser:152
msgid "Only root may add a user or group to the system.\n"
msgstr ""
"Seul le superutilisateur est autorisé à ajouter un utilisateur ou un groupe "
"au système.\n"
#: ../adduser:208
#, perl-format
msgid "Warning: The home dir %s you specified already exists.\n"
msgstr ""
"Attention ! Le répertoire personnel que vous avez indiqué (%s) existe déjà.\n"
#: ../adduser:210
#, perl-format
msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
msgstr ""
"Attention ! Impossible d'accéder au répertoire personnel que vous avez "
"indiqué (%s) : %s.\n"
""",
)
|