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
1=== modified file 'lib/lp/registry/doc/distribution-sourcepackage.txt'
2--- lib/lp/registry/doc/distribution-sourcepackage.txt 2009-09-19 08:14:43 +0000
3+++ lib/lp/registry/doc/distribution-sourcepackage.txt 2009-11-17 21:21:15 +0000
4@@ -1,7 +1,7 @@
5 = Distribution Source Packages =
6
7 A distribution source package represents a named source package in a
8-distribution, independant of any particular release of that source
9+distribution, independent of any particular release of that source
10 package.
11
12 This is useful for, among other things, tracking bugs in source
13@@ -59,36 +59,53 @@
14
15 Current overall publications:
16
17- >>> alsa_utils = ubuntu.getSourcePackage("alsa-utils")
18- >>> pub = alsa_utils.latest_overall_publication
19- >>> (pub.sourcepackagerelease.sourcepackagename.name,
20- ... pub.sourcepackagerelease.version,
21- ... pub.distroseries.name,
22- ... pub.status)
23- (u'alsa-utils',
24- u'1.0.9a-4ubuntu1',
25- u'hoary',
26- <DBItem PackagePublishingStatus.PUBLISHED, (2) Published>)
27- >>> linux_source = ubuntu.getSourcePackage("linux-source-2.6.15")
28- >>> pub = linux_source.latest_overall_publication
29- >>> (pub.sourcepackagerelease.sourcepackagename.name,
30- ... pub.sourcepackagerelease.version,
31- ... pub.distroseries.name,
32- ... pub.status)
33- (u'linux-source-2.6.15',
34- u'2.6.15.3',
35- u'hoary',
36- <DBItem PackagePublishingStatus.PUBLISHED, (2) Published>)
37- >>> commercial = ubuntu.getSourcePackage("commercialpackage")
38- >>> pub = linux_source.latest_overall_publication
39- >>> (pub.sourcepackagerelease.sourcepackagename.name,
40- ... pub.sourcepackagerelease.version,
41- ... pub.distroseries.name,
42- ... pub.status)
43- (u'linux-source-2.6.15',
44- u'2.6.15.3',
45- u'hoary',
46- <DBItem PackagePublishingStatus.PUBLISHED, (2) Published>)
47+A DistributionSourcePackage has a property called 'latest_overall_publication'
48+which returns the latest overall relevant publication. Relevant is currently
49+defined as being either published or obsolete with published being preferred,
50+sorted by distroseries and component with publications in proposed and backports
51+excluded.
52+
53+ >>> from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
54+ >>> from lp.soyuz.interfaces.publishing import PackagePublishingStatus
55+ >>> publisher = SoyuzTestPublisher()
56+ >>> publisher.prepareBreezyAutotest()
57+ >>> warty = ubuntu['warty']
58+ >>> hoary = ubuntu['hoary']
59+
60+This demonstrates the scenario where a newer distroseries becomes obsolete
61+before an older distroseries. The latest_overall_publication property will
62+return the publication from the older distroseries because a published
63+publication is considered more relevant than an obsolete publication.
64+
65+Note that the component of the package in the newer obsolete distroseries
66+is 'main' and in the older distroseries it is 'universe'.
67+
68+ >>> compiz_publication_warty = publisher.getPubSource(
69+ ... sourcename='compiz', version='0.01-1ubuntu1', distroseries=warty,
70+ ... status=PackagePublishingStatus.PUBLISHED, component='universe')
71+ >>> compiz_publication_hoary = publisher.getPubSource(
72+ ... sourcename='compiz', version='0.01-1ubuntu1', distroseries=hoary,
73+ ... status=PackagePublishingStatus.OBSOLETE, component='main')
74+ >>> compiz = ubuntu.getSourcePackage('compiz')
75+ >>> print compiz.latest_overall_publication.component.name
76+ universe
77+
78+When more than one published publication exists in a single distroseries,
79+latest_overall_publication will favor updates over security and security over
80+release.
81+
82+ >>> from lp.registry.interfaces.pocket import PackagePublishingPocket
83+ >>> firefox_publication_warty = publisher.getPubSource(
84+ ... sourcename='firefox', version='0.01-1ubuntu1', distroseries=hoary,
85+ ... status=PackagePublishingStatus.PUBLISHED, component='main',
86+ ... pocket=PackagePublishingPocket.RELEASE)
87+ >>> firefox_publication_hoary = publisher.getPubSource(
88+ ... sourcename='firefox', version='0.01-1ubuntu1.1', distroseries=hoary,
89+ ... status=PackagePublishingStatus.PUBLISHED, component='main',
90+ ... pocket=PackagePublishingPocket.SECURITY)
91+ >>> firefox = ubuntu.getSourcePackage('firefox')
92+ >>> print firefox.latest_overall_publication.pocket.name
93+ SECURITY
94
95 === Release-related properties ===
96
97@@ -164,7 +181,6 @@
98 ... print pub.distroseries.name, pub.status.name, is_removed
99 breezy-autotest DELETED True
100
101-
102 == __hash__ ==
103
104 DistributionSourcePackage defines a custom __hash__ method, so that
105@@ -192,7 +208,6 @@
106 >>> mapping[ubuntu.getSourcePackage('mozilla-firefox')] is firefox_marker
107 True
108
109-
110 == Upstream links ==
111
112 DistributionSourcePackages can be linked to upstream Products. You can
113@@ -209,7 +224,6 @@
114 >>> print pmount.upstream_product
115 None
116
117-
118 == Finding archives where this package is published ==
119
120 A distribution source package can also find which archives
121
122=== modified file 'lib/lp/registry/model/distributionsourcepackage.py'
123--- lib/lp/registry/model/distributionsourcepackage.py 2009-10-26 18:41:50 +0000
124+++ lib/lp/registry/model/distributionsourcepackage.py 2009-11-17 21:21:15 +0000
125@@ -20,33 +20,30 @@
126 from storm.locals import Int, Reference, Store, Storm, Unicode
127 from zope.interface import implements
128
129+from canonical.database.sqlbase import sqlvalues
130+from canonical.launchpad.database.emailaddress import EmailAddress
131+from canonical.launchpad.database.structuralsubscription import (
132+ StructuralSubscriptionTargetMixin)
133+from canonical.launchpad.interfaces.lpstorm import IStore
134+from canonical.lazr.utils import smartquote
135 from lp.answers.interfaces.questiontarget import IQuestionTarget
136-from lp.registry.interfaces.product import IDistributionSourcePackage
137-from canonical.database.sqlbase import sqlvalues
138 from lp.bugs.model.bug import BugSet, get_bug_tags_open_count
139 from lp.bugs.model.bugtarget import BugTargetBase
140 from lp.bugs.model.bugtask import BugTask
141 from lp.code.model.hasbranches import HasBranchesMixin, HasMergeProposalsMixin
142+from lp.registry.interfaces.pocket import PackagePublishingPocket
143+from lp.registry.interfaces.product import IDistributionSourcePackage
144+from lp.registry.model.karma import KarmaTotalCache
145+from lp.registry.model.person import Person
146+from lp.registry.model.sourcepackage import (
147+ SourcePackage, SourcePackageQuestionTargetMixin)
148 from lp.soyuz.interfaces.archive import ArchivePurpose
149 from lp.soyuz.interfaces.publishing import PackagePublishingStatus
150 from lp.soyuz.model.archive import Archive
151 from lp.soyuz.model.distributionsourcepackagerelease import (
152 DistributionSourcePackageRelease)
153-from lp.soyuz.model.publishing import (
154- SourcePackagePublishingHistory)
155-from lp.soyuz.model.sourcepackagerelease import (
156- SourcePackageRelease)
157-from lp.registry.model.karma import KarmaTotalCache
158-from lp.registry.model.person import Person
159-from lp.registry.model.sourcepackage import (
160- SourcePackage, SourcePackageQuestionTargetMixin)
161-from canonical.launchpad.database.emailaddress import EmailAddress
162-from canonical.launchpad.database.structuralsubscription import (
163- StructuralSubscriptionTargetMixin)
164-from canonical.launchpad.interfaces.lpstorm import IStore
165-
166-from canonical.lazr.utils import smartquote
167-
168+from lp.soyuz.model.publishing import SourcePackagePublishingHistory
169+from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
170
171 class DistributionSourcePackage(BugTargetBase,
172 SourcePackageQuestionTargetMixin,
173@@ -151,15 +148,19 @@
174 SourcePackageRelease.id AND
175 SourcePackageRelease.sourcepackagename = %s AND
176 SourcePackagePublishingHistory.archive IN %s AND
177- pocket NOT IN (30, 40) AND
178- status in (2,5)""" %
179+ pocket NOT IN (%s, %s) AND
180+ status in (%s, %s)""" %
181 sqlvalues(self.distribution,
182 self.sourcepackagename,
183- self.distribution.all_distro_archive_ids),
184+ self.distribution.all_distro_archive_ids,
185+ PackagePublishingPocket.PROPOSED,
186+ PackagePublishingPocket.BACKPORTS,
187+ PackagePublishingStatus.PUBLISHED,
188+ PackagePublishingStatus.OBSOLETE),
189 clauseTables=["SourcePackagePublishingHistory",
190 "SourcePackageRelease",
191 "DistroSeries"],
192- orderBy=["-status",
193+ orderBy=["status",
194 SQLConstant(
195 "to_number(DistroSeries.version, '99.99') DESC"),
196 "-pocket"])