Merge lp:~henninge/launchpad/db-devel-688519-getusedtranslationmessage into lp:launchpad/db-devel
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Curtis Hovey on 2010-12-17 | ||||
| Approved revision: | no longer in the source branch. | ||||
| Merged at revision: | 10070 | ||||
| Proposed branch: | lp:~henninge/launchpad/db-devel-688519-getusedtranslationmessage | ||||
| Merge into: | lp:launchpad/db-devel | ||||
| Diff against target: |
842 lines (+199/-170) 17 files modified
lib/lp/testing/factory.py (+12/-11) lib/lp/translations/doc/poimport.txt (+4/-4) lib/lp/translations/doc/potmsgset.txt (+8/-8) lib/lp/translations/interfaces/potmsgset.py (+14/-0) lib/lp/translations/model/potmsgset.py (+34/-12) lib/lp/translations/model/side.py (+3/-4) lib/lp/translations/model/translatablemessage.py (+4/-3) lib/lp/translations/model/translationmessage.py (+3/-0) lib/lp/translations/scripts/message_sharing_migration.py (+6/-8) lib/lp/translations/scripts/tests/test_message_sharing_migration.py (+3/-3) lib/lp/translations/tests/helpers.py (+7/-19) lib/lp/translations/tests/potmsgset-update-translation.txt (+11/-10) lib/lp/translations/tests/test_potmsgset.py (+72/-66) lib/lp/translations/tests/test_suggestions.py (+2/-3) lib/lp/translations/tests/test_translatablemessage.py (+5/-8) lib/lp/translations/utilities/tests/import-flags.txt (+2/-2) lib/lp/translations/utilities/tests/test_xpi_import.py (+9/-9) |
||||
| To merge this branch: | bzr merge lp:~henninge/launchpad/db-devel-688519-getusedtranslationmessage | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Curtis Hovey (community) | code | 2010-12-17 | Approve on 2010-12-17 |
| j.c.sackett (community) | code* | 2010-12-16 | Approve on 2010-12-17 |
|
Review via email:
|
|||
Commit Message
[r=jcsackett,
Description of the Change
= Summary =
The goal of this branch was to find an alternative for methods that use
POTMsgSet.
getCurrentTrans
getSharedTransl
used in all places so that the old methods have to be kept around.
The branch is quite long because a lot of call sites could still be updated.
Another fix that came up while doing this was to remove the use of
TranslationMess
uses the new model. In the new model the work done by them has been moved to
higher levels.
A few more other things were fixed, see the details below.
== Proposed fix ==
The getImportedTran
replaced by getOtherTranslation and getSharedTransl
getCurrentTrans
The makeCurrent* methods were called in the central
TranslationSide
respective flag attributes directly without checking if other flags need to
be cleared first. Only one call site needed to be fixed because it did not
unset a flag properly.
== Pre-implementation notes ==
More and earlier pre-implementation chatting with Danilo would have
prevented some turns that this branch took but it's OK now. There are a lot
more things that could be fixed but they should not become part of this
branch.
== Implementation details ==
Any change not mentioned here is either a mechanical replacement or was
already mentioned.
lib/lp/
The factory method makeCurrentTran
message properly which was now causing tests to fail. That now routes
through makeDivergedTra
lib/lp/
The singular_text property was patched to work with the new model by looking
for English translations on both sides. That approach is still subject to
discussion but works for now.
An added setFlag call fixes setCurrentTrans
lib/lp/
I found that get_all_
it explicitely looks for diverged messages. Also its implementation and also
its call site were overly complicated. I fixed it to be simpler.
lib/lp/
The bigger test changes in here were the incentive for this branch. Some of
the concepts tested here don't apply any more, so I updated the test to be
more useful. This could be done for a lot more tests but not in this branch.
I just saw that I left two tests disabled in there. They should pass now,
though. I will re-enable them an push the change.
lib/lp/
The factory method makeCurrentTran
date_reviewed parameters.
== Tests ==
Best to run all translations tests.
bin/test -vvm lp.translations
== Demo and Q/A ==
QA is part of the QA for the recife branch.
= Launchpad lint =
I removed a lot of lint as you can see in the branch.
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
./lib/lp/
1: narrative uses a moin header.
14: narrative uses a moin header.
23: source exceeds 78 characters.
91: narrative uses a moin header.
242: narrative exceeds 78 characters.
./lib/lp/
307: W291 trailing whitespace
307: Line has trailing whitespace.
| Henning Eggers (henninge) wrote : | # |
Am 16.12.2010 19:33, schrieb j.c.sackett:
> Review: Needs Information code*
> Henninge--
>
> This is quite a branch.
I know. Sorry about that.
>
> Is it safe to assume this is preceding further work?
Yes, there is more to come. I am sorry I forgot to mention the big picture. We
recently merged our "recife" feature branch which introduces a new model to
share translations between Ubuntu and upstream projects. This is not primarily
a change in the database model (some column and index renaming) but in the way
we use it. The work is mostly done but there is still a lot of cruft flying
around. The work to remove that is ongoing and this branch is part of it.
Thank you very much for ploughing through this branch. Please find my comments
below.
Cheers,
Henning
>> === modified file 'lib/lp/
>> --- lib/lp/
>> +++ lib/lp/
>> @@ -245,10 +245,17 @@
>> self._cached_
>> return self._cached_
>>
>> - # Singular text is stored as an "English translation."
>> - translation_message = self.getCurrent
>> - potemplate=None,
>> - language=
>> + # Singular text is stored as an "English translation." Search on
>> + # both sides.
>> + # XXX henninge 2010-12-14, bug=690196 This may still need some
>> + # re-thinking. Maybe even add "getAnyCurrentT
>> + translation_message = self.getCurrent
>> + None, getUtility(
>> + TranslationSide
>> + if translation_message is None:
>> + translation_message = self.getCurrent
>> + None, getUtility(
>> + TranslationSide
>> if translation_message is not None:
>> msgstr0 = translation_
>> if msgstr0 is not None:
>
> I'm not sure I understand what's going on here; could you explain more what
> the possible re-thinking entails?
>
> If I understand correctly, a new model requires looking at both UPSTREAM
> and UBUNTU translations to see if anything exists;
Well, that is what needs to be discussed. ;) Looking on both sides is the safe
approach for now to make sure we find anything. The bug report suggests other
solution, including a model change.
> I'm guessing the new model is the side.py thing? Or is this a new "conceptual model" ?
The TranslationSide
model. Another one is the setCurrentTrans
is now doing what updateTranslation used to do.
Along with introducing the new model, we did some major restructuring in the
code because the old code (mainly updateTranslation) is too complex (in a bad
way) to try and change it to the new model. We now have more smaller methods
that share the work that updateTranslation used to do.
>
>> @@ -335,6 +343,18...
| j.c.sackett (jcsackett) wrote : | # |
Henning--
Thanks for addressing my comments and questions.
>> I know this method already existed, but as the use of assert statements has
>> become deprecated, it wouldn't hurt to clean this up into a normal,
>> more informative exception.
>
>Hm, I have not heard of that deprecation yet. The style guide points to
>https:/
>which suggests that this is a correct use of an assert statement.
I hadn't seen that page; my understanding was that we were removing them from lp code, but that page makes a strong argument in your favor. I'll drop the issue, thanks for pointing me to those docs.
I look forwards to the future branches that continue cleaning this up, thanks for the start!

Henninge--
This is quite a branch.
Is it safe to assume this is preceding further work? I like the changes, but it seems like this introduces yet another way to do things without getting rid of the old way that I think this branch is supposed to cleanup.
Overall, there's a lot of cleanup in this branch I appreciate. I have some other questions below and a few commenting nitpicks/questions. Feel free to answer here or track me down in IRC.
> === modified file 'lib/lp/ testing/ factory. py' testing/ factory. py 2010-12-15 04:45:54 +0000 testing/ factory. py 2010-12-16 16:04:00 +0000 singular_ text, translations, language. pluralforms) setCurrentTrans lation( ionOrigin. ROSETTAWEB, other_side= current_ other) roxy(message) potemplate = pofile.potemplate edTranslationMe ssage( setCurrentTrans lation( ionOrigin. ROSETTAWEB, other_side= current_ other) roxy(message) .date_created = date_created date_created = date_created markReviewed( reviewer, date_reviewed)
> --- lib/lp/
> +++ lib/lp/
> @@ -2671,24 +2671,25 @@
> potmsgset.
> pofile.
>
> - message = potmsgset.
> - pofile, translator, translations,
> - RosettaTranslat
> - share_with_
> - naked_message = removeSecurityP
> -
> if diverged:
> - naked_message.
> + message = self.makeDiverg
> + pofile, potmsgset, translator, reviewer,
> + translations, date_created)
> + else:
> + message = potmsgset.
> + pofile, translator, translations,
> + RosettaTranslat
> + share_with_
> + if date_created is not None:
> + removeSecurityP
>
> - if date_created is not None:
> - naked_message.
> message.
>
> return message
Thanks for improving the use of naked objects through that stretch.
> === modified file 'lib/lp/ translations/ model/potmsgset .py' translations/ model/potmsgset .py 2010-12-02 16:13:51 +0000 translations/ model/potmsgset .py 2010-12-16 16:04:00 +0000 singular_ text = self.msgid_ singular. msgid singular_ text TranslationMess age( getUtility( ILaunchpadCeleb rities) .english) ranslation" . Translation( ILaunchpadCeleb rities) .english, .UBUNTU) Translation( ILaunchpadCeleb rities) .english, .UPSTREAM) message. msgstr0
> --- lib/lp/
> +++ lib/lp/
> @@ -245,10 +245,17 @@
> self._cached_
> return self._cached_
>
> - # Singular text is stored as an "English translation."
> - translation_message = self.getCurrent
> - potemplate=None,
> - language=
> + # Singular text is stored as an "English translation." Search on
> + # both sides.
> + # XXX henninge 2010-12-14, bug=690196 This may still need some
> + # re-thinking. Maybe even add "getAnyCurrentT
> + translation_message = self.getCurrent
> + None, getUtility(
> + TranslationSide
> + if translation_message is None:
> + translation_message = self.getCurrent
> + None, getUtility(
> + TranslationSide
> if translation_message is not None:
> msgstr0 = translation_
> ...