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

Proposed by Данило Шеган
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~danilo/launchpad/bug-562450
Merge into: lp:launchpad
Diff against target: 138 lines (+49/-12)
2 files modified
lib/lp/soyuz/doc/distroseriesqueue-translations.txt (+43/-9)
lib/lp/soyuz/model/queue.py (+6/-3)
To merge this branch: bzr merge lp:~danilo/launchpad/bug-562450
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+23383@code.launchpad.net

Commit message

Do not publish translations for package rebuilds.

Description of the change

= Bug 562450 =

People complain when stuff happens without them being aware of it. One of such things is when translations get imported and attributed to them.

So, we had a rebuild of a package from Intrepid and that ended up causing a translations import. One file had no Last-Translator set, so even translations got assigned to the original packager from few years back. It came as a surprise to the packager.

== Proposed fix ==

From discussion with Julian, we should ignore not just PPAs, but all the packages from archives with purposes not in MAIN_ARCHIVE_PURPOSES. Let's do it.

Lint has a bunch of problems which I am pretty sure have nothing to do with me, and might be related to my system being a bit screwed.

== Tests ==

This would benefit from unit testing which is currently done in a doctest. Ugh. If I didn't have many other important things on my plate, I'd clean it up already. Please don't shoot me.

 bin/test -vvt distroseriesqueue-translations

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/soyuz/doc/distroseriesqueue-translations.txt
  lib/lp/soyuz/model/queue.py

== Pylint notices ==

lib/lp/soyuz/model/queue.py
    23: [F0401] Unable to import 'storm.locals'
    24: [F0401] Unable to import 'storm.store'
    26: [F0401] Unable to import 'zope.component'
    32: [F0401] Unable to import 'lp.archivepublisher.config'
    33: [F0401] Unable to import 'lp.archivepublisher.customupload'
    34: [F0401] Unable to import 'lp.archivepublisher.utils'
    35: [F0401] Unable to import 'lp.archiveuploader.changesfile'
    36: [F0401] Unable to import 'lp.archiveuploader.tagfiles'
    37: [F0401] Unable to import 'lp.archiveuploader.utils'
    38: [F0401] Unable to import 'canonical.cachedproperty'
    39: [F0401] Unable to import 'canonical.config'
    40: [F0401] Unable to import 'canonical.database.constants'
    41: [F0401] Unable to import 'canonical.database.datetimecol'
    42: [F0401] Unable to import 'canonical.database.enumcol'
    44: [F0401] Unable to import 'canonical.encoding'
    45: [F0401] Unable to import 'canonical.launchpad.helpers'
    46: [F0401] Unable to import 'lp.soyuz.interfaces.archive'
    47: [F0401] Unable to import 'lp.soyuz.interfaces.binarypackagerelease'
    49: [F0401] Unable to import 'canonical.launchpad.interfaces.launchpad'
    50: [F0401] Unable to import 'lp.soyuz.interfaces.queue'
    52: [F0401] Unable to import 'lp.registry.interfaces.person'
    53: [F0401] Unable to import 'lp.registry.interfaces.pocket'
    55: [F0401] Unable to import 'lp.soyuz.interfaces.publishing'
    57: [F0401] Unable to import 'lp.soyuz.interfaces.queue'
    63: [F0401] Unable to import 'lp.soyuz.pas'
    64: [F0401] Unable to import 'canonical.launchpad.mail'
    66: [F0401] Unable to import 'lp.soyuz.scripts.processaccepted'
    68: [F0401] Unable to import 'lp.soyuz.scripts.packagecopier'
    69: [F0401] Unable to import 'canonical.librarian.interfaces'
    70: [F0401] Unable to import 'canonical.librarian.utils'
    71: [F0401] Unable to import 'canonical.launchpad.webapp'
    72: [F0401] Unable to import 'canonical.launchpad.webapp.interfaces'
    73: [F0401] Unable to import 'canonical.launchpad.interfaces.lpstorm'
    1678: [F0401, PackageUploadCustom.publish_DEBIAN_INSTALLER] Unable to import 'lp.archivepublisher.debian_installer'
    1687: [F0401, PackageUploadCustom.publish_DIST_UPGRADER] Unable to import 'lp.archivepublisher.dist_upgrader'
    1696: [F0401, PackageUploadCustom.publish_DDTP_TARBALL] Unable to import 'lp.archivepublisher.ddtp_tarball'
    1779: [F0401, PackageUploadSet.findSourceUpload] Unable to import 'lp.registry.model.distroseries'
    1780: [F0401, PackageUploadSet.findSourceUpload] Unable to import 'lp.registry.model.sourcepackagename'
    1781: [F0401, PackageUploadSet.findSourceUpload] Unable to import 'lp.soyuz.model.sourcepackagerelease'

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/soyuz/doc/distroseriesqueue-translations.txt'
2--- lib/lp/soyuz/doc/distroseriesqueue-translations.txt 2010-03-12 13:39:33 +0000
3+++ lib/lp/soyuz/doc/distroseriesqueue-translations.txt 2010-04-14 11:56:24 +0000
4@@ -297,8 +297,35 @@
5
6 >>> queue_item.customfiles[0].publish(mock_logger)
7 DEBUG: Publishing custom pmount, pmount_0.9.7-2ubuntu2_amd64_translations.tar.gz to ubuntu/dapper
8- DEBUG: Skipping translations since it is a PPA.
9-
10+ DEBUG: Skipping translations since its purpose is not in
11+ MAIN_ARCHIVE_PURPOSES.
12+
13+ # And this time, we see that there are no entries imported in the queue.
14+ >>> translation_import_queue.getAllEntries(target=ubuntu).count()
15+ 0
16+ >>> transaction.abort()
17+
18+
19+== Translations from a rebuild ==
20+
21+Translations coming from rebuilt packages are also ignored.
22+
23+ >>> from lp.registry.interfaces.person import IPersonSet
24+ >>> from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet
25+
26+ >>> foobar_archive = getUtility(IArchiveSet).new(
27+ ... purpose=ArchivePurpose.COPY,
28+ ... owner=getUtility(IPersonSet).getByName('name16'),
29+ ... name='rebuilds')
30+
31+ >>> dapper = getUtility(IDistributionSet)['ubuntu']['dapper']
32+ >>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
33+ >>> queue_item.archive = foobar_archive
34+
35+ >>> queue_item.customfiles[0].publish(mock_logger)
36+ DEBUG: Publishing custom pmount, pmount_0.9.7-2ubuntu2_amd64_translations.tar.gz to ubuntu/dapper
37+ DEBUG: Skipping translations since its purpose is not in
38+ MAIN_ARCHIVE_PURPOSES.
39
40 # And this time, we see that there are no entries imported in the queue.
41 >>> translation_import_queue.getAllEntries(target=ubuntu).count()
42@@ -314,6 +341,8 @@
43 >>> from zope.interface import implements
44 >>> from canonical.launchpad.interfaces import ILaunchpadCelebrities
45 >>> from lp.soyuz.model.queue import PackageUploadCustom
46+ >>> from lp.soyuz.interfaces.archive import (
47+ ... IArchive, ArchivePurpose)
48 >>> from lp.soyuz.interfaces.queue import (
49 ... IPackageUpload, IPackageUploadCustom)
50 >>> from lp.soyuz.interfaces.queue import PackageUploadCustomFormat
51@@ -323,6 +352,11 @@
52 ... ISourcePackageRelease)
53 >>> from lp.registry.interfaces.pocket import PackagePublishingPocket
54
55+ >>> class MockArchive:
56+ ... implements(IArchive)
57+ ... def __init__(self, purpose):
58+ ... self.purpose = purpose
59+
60 >>> class MockSourcePackageRelease:
61 ... implements(ISourcePackageRelease)
62 ... def __init__(self, component, creator):
63@@ -338,14 +372,13 @@
64
65 >>> class MockPackageUpload:
66 ... implements(IPackageUpload)
67- ... def __init__(self, pocket, auto_sync, sourcepackagerelease):
68+ ... def __init__(self, pocket, auto_sync, sourcepackagerelease,
69+ ... archive):
70 ... self.id = 1
71 ... self.pocket = pocket
72 ... self.auto_sync = auto_sync
73 ... self.sourcepackagerelease = sourcepackagerelease
74- ...
75- ... def isPPA(self):
76- ... return False
77+ ... self.archive = archive
78 ...
79 ... def isAutoSyncUpload(self, changed_by_email=None):
80 ... return self.auto_sync
81@@ -363,10 +396,11 @@
82
83 >>> katie = getUtility(ILaunchpadCelebrities).katie
84 >>> release_pocket = PackagePublishingPocket.RELEASE
85+ >>> archive = MockArchive(ArchivePurpose.PRIMARY)
86
87 >>> katie_sourcepackagerelease = MockSourcePackageRelease('main', katie)
88 >>> sync_package_upload = MockPackageUpload(
89- ... release_pocket, True, katie_sourcepackagerelease)
90+ ... release_pocket, True, katie_sourcepackagerelease, archive)
91 >>> sync_package_upload.isAutoSyncUpload()
92 True
93 >>> translations_upload = MockPackageUploadCustom()
94@@ -377,7 +411,7 @@
95 Non-auto-sync uploads by 'katie' still indicate 'katie' as the uploader.
96
97 >>> non_sync_package_upload = MockPackageUpload(
98- ... release_pocket, False, katie_sourcepackagerelease)
99+ ... release_pocket, False, katie_sourcepackagerelease, archive)
100 >>> non_sync_package_upload.isAutoSyncUpload()
101 False
102 >>> translations_upload.packageupload = non_sync_package_upload
103@@ -390,7 +424,7 @@
104 >>> carlos = person_set.getByName('carlos')
105 >>> carlos_sourcepackagerelease = MockSourcePackageRelease('main', carlos)
106 >>> carlos_package_upload = MockPackageUpload(
107- ... release_pocket, False, carlos_sourcepackagerelease)
108+ ... release_pocket, False, carlos_sourcepackagerelease, archive)
109 >>> carlos_package_upload.isAutoSyncUpload()
110 False
111 >>> translations_upload.packageupload = carlos_package_upload
112
113=== modified file 'lib/lp/soyuz/model/queue.py'
114--- lib/lp/soyuz/model/queue.py 2010-04-12 11:37:48 +0000
115+++ lib/lp/soyuz/model/queue.py 2010-04-14 11:56:24 +0000
116@@ -43,6 +43,7 @@
117 from canonical.database.sqlbase import SQLBase, sqlvalues
118 from canonical.encoding import guess as guess_encoding, ascii_smash
119 from canonical.launchpad.helpers import get_email_template
120+from lp.soyuz.interfaces.archive import MAIN_ARCHIVE_PURPOSES
121 from lp.soyuz.interfaces.binarypackagerelease import (
122 BinaryPackageFormat)
123 from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
124@@ -1701,9 +1702,11 @@
125 """See `IPackageUploadCustom`."""
126 sourcepackagerelease = self.packageupload.sourcepackagerelease
127
128- # Ignore translation coming from PPA.
129- if self.packageupload.isPPA():
130- debug(logger, "Skipping translations since it is a PPA.")
131+ # Ignore translations not with main distribution purposes.
132+ if self.packageupload.archive.purpose not in MAIN_ARCHIVE_PURPOSES:
133+ debug(logger,
134+ "Skipping translations since its purpose is not "
135+ "in MAIN_ARCHIVE_PURPOSES.")
136 return
137
138 valid_pockets = (