Merge lp:~cody-somerville/launchpad/fix-bug-297709 into lp:launchpad

Proposed by Cody A.W. Somerville
Status: Merged
Approved by: Brad Crittenden
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~cody-somerville/launchpad/fix-bug-297709
Merge into: lp:launchpad
Diff against target: 196 lines (+70/-55)
2 files modified
lib/lp/registry/doc/distribution-sourcepackage.txt (+48/-34)
lib/lp/registry/model/distributionsourcepackage.py (+22/-21)
To merge this branch: bzr merge lp:~cody-somerville/launchpad/fix-bug-297709
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Julian Edwards Pending
Review via email: mp+14929@code.launchpad.net

Commit message

Fix latest_overall_publication property of DistributionSourcePackage to return the correct publication even when obsolete publications exist for a package.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Hi Cody,

Thanks for taking on this branch -- we really appreciate the contribution.

In the future note we do like a merge proposal to include a cover letter with some background information on the task. See https://code.edge.launchpad.net/~bac/launchpad/bug-483607/+merge/14925 for an example. There is a bzr plugin at https://edge.launchpad.net/lpreview-body which makes creating the cover letter very easy. Just a FYI, now on to the review.

* We try to use en_US spellings, though we don't follow it strictly, so please s/favour/favor. Also I note another typo that is not your but it would be great for you to fix s/independant/independent.

* At line 74 could you explicitly set the pocket for ff_pub_warty so the reader doesn't have to know the default?

* The test has a lot of trailing whitespace. Please delete those.

* In the code you have:

from lp.registry.model.sourcepackage import (SourcePackage,
    SourcePackageQuestionTargetMixin)

Please move that first package to the next line, which is part of our coding standards. All of the packages should be sorted alphabetically too, which they are.

* Please remove the unnecessary parens from:

from lp.soyuz.model.publishing import (SourcePackagePublishingHistory)
from lp.soyuz.model.sourcepackagerelease import (SourcePackageRelease)

* Thanks a lot for getting rid of the magic numbers!

Again, thanks for contributing this fix. The change looks great overall and will be ready to land after making the minor changes. I'm marking the proposal 'Approved' since the changes are so straightforward and the changes don't need to be re-reviewed. I'm not sure if you have permission to land this yourself but I'll be happy to do so if you cannot.

review: Approve (code)
Revision history for this message
Brad Crittenden (bac) wrote :

Cody,

Thanks for making the requested changes.

I've tried to land this branch for you but have run into some problems. Since you wrote your branch we have updated Launchpad to run with Python 2.5.

In order to me to land your branch and ensure you get credit for it I'll need you to do a 'rocketfuel-get' and in your branch merge from trunk and then re-push to Launchpad. If you run into any problems please ask on #launchpad-dev.

Thanks,
Brad

Revision history for this message
Brad Crittenden (bac) wrote :

Cody,

I tried something different and now have your branch playing on PQM. For the moment, please disregard the previous request.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/doc/distribution-sourcepackage.txt'
--- lib/lp/registry/doc/distribution-sourcepackage.txt 2009-09-19 08:14:43 +0000
+++ lib/lp/registry/doc/distribution-sourcepackage.txt 2009-11-17 21:21:15 +0000
@@ -1,7 +1,7 @@
1= Distribution Source Packages =1= Distribution Source Packages =
22
3A distribution source package represents a named source package in a3A distribution source package represents a named source package in a
4distribution, independant of any particular release of that source4distribution, independent of any particular release of that source
5package.5package.
66
7This is useful for, among other things, tracking bugs in source7This is useful for, among other things, tracking bugs in source
@@ -59,36 +59,53 @@
5959
60Current overall publications:60Current overall publications:
6161
62 >>> alsa_utils = ubuntu.getSourcePackage("alsa-utils")62A DistributionSourcePackage has a property called 'latest_overall_publication'
63 >>> pub = alsa_utils.latest_overall_publication63which returns the latest overall relevant publication. Relevant is currently
64 >>> (pub.sourcepackagerelease.sourcepackagename.name,64defined as being either published or obsolete with published being preferred,
65 ... pub.sourcepackagerelease.version,65sorted by distroseries and component with publications in proposed and backports
66 ... pub.distroseries.name,66excluded.
67 ... pub.status)67
68 (u'alsa-utils',68 >>> from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
69 u'1.0.9a-4ubuntu1',69 >>> from lp.soyuz.interfaces.publishing import PackagePublishingStatus
70 u'hoary',70 >>> publisher = SoyuzTestPublisher()
71 <DBItem PackagePublishingStatus.PUBLISHED, (2) Published>)71 >>> publisher.prepareBreezyAutotest()
72 >>> linux_source = ubuntu.getSourcePackage("linux-source-2.6.15")72 >>> warty = ubuntu['warty']
73 >>> pub = linux_source.latest_overall_publication73 >>> hoary = ubuntu['hoary']
74 >>> (pub.sourcepackagerelease.sourcepackagename.name,74
75 ... pub.sourcepackagerelease.version,75This demonstrates the scenario where a newer distroseries becomes obsolete
76 ... pub.distroseries.name,76before an older distroseries. The latest_overall_publication property will
77 ... pub.status)77return the publication from the older distroseries because a published
78 (u'linux-source-2.6.15',78publication is considered more relevant than an obsolete publication.
79 u'2.6.15.3',79
80 u'hoary',80Note that the component of the package in the newer obsolete distroseries
81 <DBItem PackagePublishingStatus.PUBLISHED, (2) Published>)81is 'main' and in the older distroseries it is 'universe'.
82 >>> commercial = ubuntu.getSourcePackage("commercialpackage")82
83 >>> pub = linux_source.latest_overall_publication83 >>> compiz_publication_warty = publisher.getPubSource(
84 >>> (pub.sourcepackagerelease.sourcepackagename.name,84 ... sourcename='compiz', version='0.01-1ubuntu1', distroseries=warty,
85 ... pub.sourcepackagerelease.version,85 ... status=PackagePublishingStatus.PUBLISHED, component='universe')
86 ... pub.distroseries.name,86 >>> compiz_publication_hoary = publisher.getPubSource(
87 ... pub.status)87 ... sourcename='compiz', version='0.01-1ubuntu1', distroseries=hoary,
88 (u'linux-source-2.6.15',88 ... status=PackagePublishingStatus.OBSOLETE, component='main')
89 u'2.6.15.3',89 >>> compiz = ubuntu.getSourcePackage('compiz')
90 u'hoary',90 >>> print compiz.latest_overall_publication.component.name
91 <DBItem PackagePublishingStatus.PUBLISHED, (2) Published>)91 universe
92
93When more than one published publication exists in a single distroseries,
94latest_overall_publication will favor updates over security and security over
95release.
96
97 >>> from lp.registry.interfaces.pocket import PackagePublishingPocket
98 >>> firefox_publication_warty = publisher.getPubSource(
99 ... sourcename='firefox', version='0.01-1ubuntu1', distroseries=hoary,
100 ... status=PackagePublishingStatus.PUBLISHED, component='main',
101 ... pocket=PackagePublishingPocket.RELEASE)
102 >>> firefox_publication_hoary = publisher.getPubSource(
103 ... sourcename='firefox', version='0.01-1ubuntu1.1', distroseries=hoary,
104 ... status=PackagePublishingStatus.PUBLISHED, component='main',
105 ... pocket=PackagePublishingPocket.SECURITY)
106 >>> firefox = ubuntu.getSourcePackage('firefox')
107 >>> print firefox.latest_overall_publication.pocket.name
108 SECURITY
92109
93=== Release-related properties ===110=== Release-related properties ===
94111
@@ -164,7 +181,6 @@
164 ... print pub.distroseries.name, pub.status.name, is_removed181 ... print pub.distroseries.name, pub.status.name, is_removed
165 breezy-autotest DELETED True182 breezy-autotest DELETED True
166183
167
168== __hash__ ==184== __hash__ ==
169185
170DistributionSourcePackage defines a custom __hash__ method, so that186DistributionSourcePackage defines a custom __hash__ method, so that
@@ -192,7 +208,6 @@
192 >>> mapping[ubuntu.getSourcePackage('mozilla-firefox')] is firefox_marker208 >>> mapping[ubuntu.getSourcePackage('mozilla-firefox')] is firefox_marker
193 True209 True
194210
195
196== Upstream links ==211== Upstream links ==
197212
198DistributionSourcePackages can be linked to upstream Products. You can213DistributionSourcePackages can be linked to upstream Products. You can
@@ -209,7 +224,6 @@
209 >>> print pmount.upstream_product224 >>> print pmount.upstream_product
210 None225 None
211226
212
213== Finding archives where this package is published ==227== Finding archives where this package is published ==
214228
215A distribution source package can also find which archives229A distribution source package can also find which archives
216230
=== modified file 'lib/lp/registry/model/distributionsourcepackage.py'
--- lib/lp/registry/model/distributionsourcepackage.py 2009-10-26 18:41:50 +0000
+++ lib/lp/registry/model/distributionsourcepackage.py 2009-11-17 21:21:15 +0000
@@ -20,33 +20,30 @@
20from storm.locals import Int, Reference, Store, Storm, Unicode20from storm.locals import Int, Reference, Store, Storm, Unicode
21from zope.interface import implements21from zope.interface import implements
2222
23from canonical.database.sqlbase import sqlvalues
24from canonical.launchpad.database.emailaddress import EmailAddress
25from canonical.launchpad.database.structuralsubscription import (
26 StructuralSubscriptionTargetMixin)
27from canonical.launchpad.interfaces.lpstorm import IStore
28from canonical.lazr.utils import smartquote
23from lp.answers.interfaces.questiontarget import IQuestionTarget29from lp.answers.interfaces.questiontarget import IQuestionTarget
24from lp.registry.interfaces.product import IDistributionSourcePackage
25from canonical.database.sqlbase import sqlvalues
26from lp.bugs.model.bug import BugSet, get_bug_tags_open_count30from lp.bugs.model.bug import BugSet, get_bug_tags_open_count
27from lp.bugs.model.bugtarget import BugTargetBase31from lp.bugs.model.bugtarget import BugTargetBase
28from lp.bugs.model.bugtask import BugTask32from lp.bugs.model.bugtask import BugTask
29from lp.code.model.hasbranches import HasBranchesMixin, HasMergeProposalsMixin33from lp.code.model.hasbranches import HasBranchesMixin, HasMergeProposalsMixin
34from lp.registry.interfaces.pocket import PackagePublishingPocket
35from lp.registry.interfaces.product import IDistributionSourcePackage
36from lp.registry.model.karma import KarmaTotalCache
37from lp.registry.model.person import Person
38from lp.registry.model.sourcepackage import (
39 SourcePackage, SourcePackageQuestionTargetMixin)
30from lp.soyuz.interfaces.archive import ArchivePurpose40from lp.soyuz.interfaces.archive import ArchivePurpose
31from lp.soyuz.interfaces.publishing import PackagePublishingStatus41from lp.soyuz.interfaces.publishing import PackagePublishingStatus
32from lp.soyuz.model.archive import Archive42from lp.soyuz.model.archive import Archive
33from lp.soyuz.model.distributionsourcepackagerelease import (43from lp.soyuz.model.distributionsourcepackagerelease import (
34 DistributionSourcePackageRelease)44 DistributionSourcePackageRelease)
35from lp.soyuz.model.publishing import (45from lp.soyuz.model.publishing import SourcePackagePublishingHistory
36 SourcePackagePublishingHistory)46from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
37from lp.soyuz.model.sourcepackagerelease import (
38 SourcePackageRelease)
39from lp.registry.model.karma import KarmaTotalCache
40from lp.registry.model.person import Person
41from lp.registry.model.sourcepackage import (
42 SourcePackage, SourcePackageQuestionTargetMixin)
43from canonical.launchpad.database.emailaddress import EmailAddress
44from canonical.launchpad.database.structuralsubscription import (
45 StructuralSubscriptionTargetMixin)
46from canonical.launchpad.interfaces.lpstorm import IStore
47
48from canonical.lazr.utils import smartquote
49
5047
51class DistributionSourcePackage(BugTargetBase,48class DistributionSourcePackage(BugTargetBase,
52 SourcePackageQuestionTargetMixin,49 SourcePackageQuestionTargetMixin,
@@ -151,15 +148,19 @@
151 SourcePackageRelease.id AND148 SourcePackageRelease.id AND
152 SourcePackageRelease.sourcepackagename = %s AND149 SourcePackageRelease.sourcepackagename = %s AND
153 SourcePackagePublishingHistory.archive IN %s AND150 SourcePackagePublishingHistory.archive IN %s AND
154 pocket NOT IN (30, 40) AND151 pocket NOT IN (%s, %s) AND
155 status in (2,5)""" %152 status in (%s, %s)""" %
156 sqlvalues(self.distribution,153 sqlvalues(self.distribution,
157 self.sourcepackagename,154 self.sourcepackagename,
158 self.distribution.all_distro_archive_ids),155 self.distribution.all_distro_archive_ids,
156 PackagePublishingPocket.PROPOSED,
157 PackagePublishingPocket.BACKPORTS,
158 PackagePublishingStatus.PUBLISHED,
159 PackagePublishingStatus.OBSOLETE),
159 clauseTables=["SourcePackagePublishingHistory",160 clauseTables=["SourcePackagePublishingHistory",
160 "SourcePackageRelease", 161 "SourcePackageRelease",
161 "DistroSeries"],162 "DistroSeries"],
162 orderBy=["-status",163 orderBy=["status",
163 SQLConstant(164 SQLConstant(
164 "to_number(DistroSeries.version, '99.99') DESC"),165 "to_number(DistroSeries.version, '99.99') DESC"),
165 "-pocket"])166 "-pocket"])