Merge lp:~danilo/launchpad/bug-669831 into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 11953
Proposed branch: lp:~danilo/launchpad/bug-669831
Merge into: lp:launchpad
Prerequisite: lp:~danilo/launchpad/bzr-export-pofile-gathering
Diff against target: 53 lines (+22/-1)
3 files modified
lib/lp/translations/doc/translations-export-to-branch.txt (+2/-0)
lib/lp/translations/scripts/tests/test_translations_to_branch.py (+18/-0)
lib/lp/translations/scripts/translations_to_branch.py (+2/-1)
To merge this branch: bzr merge lp:~danilo/launchpad/bug-669831
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+41228@code.launchpad.net

Commit message

[r=allenap][ui=none][bug=669831] Export POFiles to bzr branch when only a template is changed.

Description of the change

= 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.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/doc/translations-export-to-branch.txt'
2--- lib/lp/translations/doc/translations-export-to-branch.txt 2010-10-18 22:24:59 +0000
3+++ lib/lp/translations/doc/translations-export-to-branch.txt 2010-11-19 17:43:29 +0000
4@@ -186,6 +186,8 @@
5 >>> script.simulated_latest_commit = now
6 >>> main_pofile.date_changed = now - timedelta(days=3)
7 >>> module_pofile.date_changed = now - timedelta(days=4)
8+ >>> module_pofile.potemplate.date_last_updated = now - timedelta(days=5)
9+ >>> transaction.commit()
10 >>> old_pofile.date_changed = now - timedelta(days=5)
11
12 >>> script.main()
13
14=== modified file 'lib/lp/translations/scripts/tests/test_translations_to_branch.py'
15--- lib/lp/translations/scripts/tests/test_translations_to_branch.py 2010-11-18 20:31:20 +0000
16+++ lib/lp/translations/scripts/tests/test_translations_to_branch.py 2010-11-19 17:43:29 +0000
17@@ -318,6 +318,24 @@
18 pofile.potemplate.productseries,
19 date_in_the_future)))
20
21+ def test_findChangedPOFiles_unchanged_template_changed(self):
22+ # If a POFile has been changed before changed_since date,
23+ # and template has been updated after it, POFile is still
24+ # considered changed and thus returned.
25+ pofile = self.factory.makePOFile()
26+ date_in_the_future = (
27+ datetime.datetime.now(pytz.UTC) + datetime.timedelta(1))
28+ date_in_the_far_future = (
29+ datetime.datetime.now(pytz.UTC) + datetime.timedelta(2))
30+ pofile.potemplate.date_last_updated = date_in_the_far_future
31+
32+ exporter = ExportTranslationsToBranch(test_args=[])
33+ self.assertEquals(
34+ [pofile],
35+ list(exporter._findChangedPOFiles(
36+ pofile.potemplate.productseries,
37+ date_in_the_future)))
38+
39
40 class TestExportToStackedBranch(TestCaseWithFactory):
41 """Test workaround for bzr bug 375013."""
42
43=== modified file 'lib/lp/translations/scripts/translations_to_branch.py'
44--- lib/lp/translations/scripts/translations_to_branch.py 2010-11-18 20:31:20 +0000
45+++ lib/lp/translations/scripts/translations_to_branch.py 2010-11-19 17:43:29 +0000
46@@ -174,7 +174,8 @@
47 for template in subset:
48 for pofile in template.pofiles:
49 if (changed_since is None or
50- pofile.date_changed > changed_since):
51+ pofile.date_changed > changed_since or
52+ template.date_last_updated > changed_since):
53 yield pofile
54
55