launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01959
[Merge] lp:~danilo/launchpad/bug-669831 into lp:launchpad/devel
Данило Шеган has proposed merging lp:~danilo/launchpad/bug-669831 into lp:launchpad/devel with lp:~danilo/launchpad/bzr-export-pofile-gathering as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#669831 obsolete translations exported to the branch
https://bugs.launchpad.net/bugs/669831
= Bug 669831 =
In our export translations to bzr branches feature, we optimize the export so as not to repeatedly export translation files (POFile objects) if they have not changed. However, it's possible that a PO file is changed (or at least needs to be re-exported) even if it was not directly changed: this happens if a new template has been imported (in i18n terminology, this is called "merging PO file with the template": Launchpad does this transparently and cheaply without having to change any data structures, but other tools depend on it happening explicitely, thus bug 669831 was filed).
When a new template is imported, POTemplate's date_last_updated attribute is updated. So, let's use that in addition to checking if POFile is directly changed to decide if a POFile needs exporting.
= Tests =
bin/test -cvvt translations_to_branch
= Demo & QA =
We'll have to set-up a translation for a project with translation export to bzr and then simply re-import the POTemplate and then do another translation export seeing how all PO files for the template are exported. Basically, just try it out.
--
https://code.launchpad.net/~danilo/launchpad/bug-669831/+merge/41228
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~danilo/launchpad/bug-669831 into lp:launchpad/devel.
=== modified file 'lib/lp/translations/scripts/tests/test_translations_to_branch.py'
--- lib/lp/translations/scripts/tests/test_translations_to_branch.py 2010-11-18 20:51:31 +0000
+++ lib/lp/translations/scripts/tests/test_translations_to_branch.py 2010-11-18 20:51:32 +0000
@@ -318,6 +318,24 @@
pofile.potemplate.productseries,
date_in_the_future)))
+ def test_findChangedPOFiles_unchanged_template_changed(self):
+ # If a POFile has been changed before changed_since date,
+ # and template has been updated after it, POFile is still
+ # considered changed and thus returned.
+ pofile = self.factory.makePOFile()
+ date_in_the_future = (
+ datetime.datetime.now(pytz.UTC) + datetime.timedelta(1))
+ date_in_the_far_future = (
+ datetime.datetime.now(pytz.UTC) + datetime.timedelta(2))
+ pofile.potemplate.date_last_updated = date_in_the_far_future
+
+ exporter = ExportTranslationsToBranch(test_args=[])
+ self.assertEquals(
+ [pofile],
+ list(exporter._findChangedPOFiles(
+ pofile.potemplate.productseries,
+ date_in_the_future)))
+
class TestExportToStackedBranch(TestCaseWithFactory):
"""Test workaround for bzr bug 375013."""
=== modified file 'lib/lp/translations/scripts/translations_to_branch.py'
--- lib/lp/translations/scripts/translations_to_branch.py 2010-11-18 20:51:31 +0000
+++ lib/lp/translations/scripts/translations_to_branch.py 2010-11-18 20:51:32 +0000
@@ -174,7 +174,8 @@
for template in subset:
for pofile in template.pofiles:
if (changed_since is None or
- pofile.date_changed > changed_since):
+ pofile.date_changed > changed_since or
+ template.date_last_updated > changed_since):
yield pofile