Merge lp:~michael.nelson/launchpad/remove-shortlist-getPublishedReleases into lp:launchpad

Proposed by Michael Nelson on 2010-08-25
Status: Merged
Approved by: Michael Nelson on 2010-08-25
Approved revision: no longer in the source branch.
Merged at revision: 11447
Proposed branch: lp:~michael.nelson/launchpad/remove-shortlist-getPublishedReleases
Merge into: lp:launchpad
Diff against target: 324 lines (+45/-39)
10 files modified
lib/lp/archiveuploader/nascentupload.py (+1/-1)
lib/lp/archiveuploader/nascentuploadfile.py (+2/-2)
lib/lp/registry/browser/distributionsourcepackage.py (+3/-2)
lib/lp/registry/doc/distroseries.txt (+11/-11)
lib/lp/registry/interfaces/distroseries.py (+3/-3)
lib/lp/registry/model/distroseries.py (+7/-5)
lib/lp/soyuz/doc/distroseries-publishing-lookups.txt (+7/-6)
lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py (+6/-4)
scripts/ftpmaster-tools/remove-package.py (+1/-1)
scripts/ftpmaster-tools/sync-source.py (+4/-4)
To merge this branch: bzr merge lp:~michael.nelson/launchpad/remove-shortlist-getPublishedReleases
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) code 2010-08-25 Approve on 2010-08-25
Review via email: mp+33645@code.launchpad.net

Commit Message

Rename DistroSeries.getPublishedReleases to getPublishedSources (as it returns source package publishing history records) and moved the use of shortlist from this model method to the browser call-site.

Description of the Change

Overview
========
This branch removes a use of canonical.launchpad.helpers.shortlist from the model method DistroSeries.getPublishedReleases() and moves it to the view where I assume its effect was intended.

It also renames getPublishedReleases() to getPublishedSources(), given that it returns a result set of SourcePackagePublishingHistory.

To test:
bin/test -vv -t distroseries.txt -t distroseries-publishing-lookups.txt -t test_initialise_distroseries

I also cleaned up some (but not all) unrelated lint.

To post a comment you must log in.
Jelmer Vernooij (jelmer) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/nascentupload.py'
2--- lib/lp/archiveuploader/nascentupload.py 2010-08-24 08:43:51 +0000
3+++ lib/lp/archiveuploader/nascentupload.py 2010-08-26 06:32:47 +0000
4@@ -589,7 +589,7 @@
5 archive = self.policy.archive
6 else:
7 archive = None
8- candidates = self.policy.distroseries.getPublishedReleases(
9+ candidates = self.policy.distroseries.getPublishedSources(
10 source_name, include_pending=True, pocket=pocket,
11 archive=archive)
12 if candidates:
13
14=== modified file 'lib/lp/archiveuploader/nascentuploadfile.py'
15--- lib/lp/archiveuploader/nascentuploadfile.py 2010-08-20 20:31:18 +0000
16+++ lib/lp/archiveuploader/nascentuploadfile.py 2010-08-26 06:32:47 +0000
17@@ -743,7 +743,7 @@
18 in DB yet (see verifySourcepackagerelease).
19 """
20 distroseries = self.policy.distroseries
21- spphs = distroseries.getPublishedReleases(
22+ spphs = distroseries.getPublishedSources(
23 self.source_name, version=self.source_version,
24 include_pending=True, archive=self.policy.archive)
25
26@@ -751,7 +751,7 @@
27 if spphs:
28 # We know there's only going to be one release because
29 # version is unique.
30- assert len(spphs) == 1, "Duplicated ancestry"
31+ assert spphs.count() == 1, "Duplicated ancestry"
32 sourcepackagerelease = spphs[0].sourcepackagerelease
33 else:
34 # XXX cprov 2006-08-09 bug=55774: Building from ACCEPTED is
35
36=== modified file 'lib/lp/registry/browser/distributionsourcepackage.py'
37--- lib/lp/registry/browser/distributionsourcepackage.py 2010-08-20 20:31:18 +0000
38+++ lib/lp/registry/browser/distributionsourcepackage.py 2010-08-26 06:32:47 +0000
39@@ -36,6 +36,7 @@
40 redirection,
41 StandardLaunchpadFacets,
42 )
43+from canonical.launchpad.helpers import shortlist
44 from canonical.launchpad.webapp.breadcrumb import Breadcrumb
45 from canonical.launchpad.webapp.menu import (
46 ApplicationMenu,
47@@ -400,10 +401,10 @@
48
49 :param sourcepackage: ISourcePackage
50 """
51- publications = sourcepackage.distroseries.getPublishedReleases(
52+ publications = sourcepackage.distroseries.getPublishedSources(
53 sourcepackage.sourcepackagename)
54 pocket_dict = {}
55- for pub in publications:
56+ for pub in shortlist(publications):
57 version = pub.source_package_version
58 pocket_dict.setdefault(version, []).append(pub)
59 return pocket_dict
60
61=== modified file 'lib/lp/registry/doc/distroseries.txt'
62--- lib/lp/registry/doc/distroseries.txt 2010-08-13 06:08:36 +0000
63+++ lib/lp/registry/doc/distroseries.txt 2010-08-26 06:32:47 +0000
64@@ -127,10 +127,10 @@
65 Warty (4.10)
66
67
68-Published releases
69-------------------
70+Published sources
71+-----------------
72
73-DistroSeries.getPublishedReleases:
74+DistroSeries.getPublishedSources:
75
76 >>> from lp.registry.model.distroseries import DistroSeries
77 >>> from lp.registry.model.sourcepackagename import SourcePackageName
78@@ -138,27 +138,27 @@
79
80 Passing a ISourcePackageName as argument:
81
82- >>> prs = warty2.getPublishedReleases(
83+ >>> prs = warty2.getPublishedSources(
84 ... SourcePackageName.byName('mozilla-firefox'))
85- >>> print len(prs)
86+ >>> print prs.count()
87 1
88 >>> print prs[0].sourcepackagerelease.sourcepackagename.name
89 mozilla-firefox
90
91 Passing a string name:
92
93- >>> print len(warty2.getPublishedReleases('mozilla-firefox'))
94+ >>> print warty2.getPublishedSources('mozilla-firefox').count()
95 1
96
97 Including pending publication records in the result:
98
99- >>> print len(warty2.getPublishedReleases('mozilla-firefox',
100- ... include_pending=True))
101+ >>> print warty2.getPublishedSources('mozilla-firefox',
102+ ... include_pending=True).count()
103 2
104
105 Not found as empty list:
106
107- >>> print len(warty2.getPublishedReleases('nosuchpackage'))
108+ >>> print warty2.getPublishedSources('nosuchpackage').count()
109 0
110
111 See distroseries-publishing-lookups.txt for more information.
112@@ -317,9 +317,9 @@
113 ... '99.2',hoary, hoary.owner)
114 >>> ids = InitialiseDistroSeries(humpy)
115 >>> ids.initialise()
116- >>> len(hoary.getPublishedReleases('pmount'))
117+ >>> hoary.getPublishedSources('pmount').count()
118 1
119- >>> len(humpy.getPublishedReleases('pmount'))
120+ >>> humpy.getPublishedSources('pmount').count()
121 1
122 >>> len(hoary['i386'].getReleasedPackages('pmount'))
123 1
124
125=== modified file 'lib/lp/registry/interfaces/distroseries.py'
126--- lib/lp/registry/interfaces/distroseries.py 2010-08-20 20:31:18 +0000
127+++ lib/lp/registry/interfaces/distroseries.py 2010-08-26 06:32:47 +0000
128@@ -533,9 +533,9 @@
129 and the value is a `IDistroSeriesSourcePackageRelease`.
130 """
131
132- def getPublishedReleases(sourcepackage_or_name, pocket=None, version=None,
133- include_pending=False, exclude_pocket=None,
134- archive=None):
135+ def getPublishedSources(sourcepackage_or_name, pocket=None, version=None,
136+ include_pending=False, exclude_pocket=None,
137+ archive=None):
138 """Return the SourcePackagePublishingHistory(s)
139
140 Given a ISourcePackageName or name.
141
142=== modified file 'lib/lp/registry/model/distroseries.py'
143--- lib/lp/registry/model/distroseries.py 2010-08-23 09:10:10 +0000
144+++ lib/lp/registry/model/distroseries.py 2010-08-26 06:32:47 +0000
145@@ -29,7 +29,10 @@
146 Join,
147 SQL,
148 )
149-from storm.store import Store
150+from storm.store import (
151+ EmptyResultSet,
152+ Store,
153+ )
154 from zope.component import getUtility
155 from zope.interface import implements
156
157@@ -52,7 +55,6 @@
158 DecoratedResultSet,
159 )
160 from canonical.launchpad.database.librarian import LibraryFileAlias
161-from canonical.launchpad.helpers import shortlist
162 from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
163 from canonical.launchpad.interfaces.lpstorm import IStore
164 from canonical.launchpad.mail import signed_message_from_string
165@@ -963,7 +965,7 @@
166 return [SourcePackage(sourcepackagename=spn, distroseries=self) for
167 spn in result]
168
169- def getPublishedReleases(self, sourcepackage_or_name, version=None,
170+ def getPublishedSources(self, sourcepackage_or_name, version=None,
171 pocket=None, include_pending=False,
172 exclude_pocket=None, archive=None):
173 """See `IDistroSeries`."""
174@@ -979,7 +981,7 @@
175 spns = getUtility(ISourcePackageNameSet)
176 spn = spns.queryByName(sourcepackage_or_name)
177 if spn is None:
178- return []
179+ return EmptyResultSet()
180
181 queries = ["""
182 sourcepackagerelease=sourcepackagerelease.id AND
183@@ -1011,7 +1013,7 @@
184 " AND ".join(queries), clauseTables = ['SourcePackageRelease'],
185 orderBy=['-id'])
186
187- return shortlist(published)
188+ return published
189
190 def isUnstable(self):
191 """See `IDistroSeries`."""
192
193=== modified file 'lib/lp/soyuz/doc/distroseries-publishing-lookups.txt'
194--- lib/lp/soyuz/doc/distroseries-publishing-lookups.txt 2010-02-09 12:32:01 +0000
195+++ lib/lp/soyuz/doc/distroseries-publishing-lookups.txt 2010-08-26 06:32:47 +0000
196@@ -1,4 +1,5 @@
197-= DistroSeries source publishing lookups =
198+DistroSeries source publishing lookups
199+======================================
200
201 IDistroSeries allows source publishing lookup via
202 getReleasedPackages method which returns a shortlist of
203@@ -60,7 +61,7 @@
204 ... all_published_main_pubs, key=operator.attrgetter('id'),
205 ... reverse=True)
206
207- >>> result = breezy_autotest.getPublishedReleases('cnews')
208+ >>> result = breezy_autotest.getPublishedSources('cnews')
209 >>> soyuz_helper.checkPubList(all_published_main_pubs, result)
210 True
211
212@@ -77,7 +78,7 @@
213 >>> all_main_pubs = sorted(
214 ... all_main_pubs, key=operator.attrgetter('id'), reverse=True)
215
216- >>> result = breezy_autotest.getPublishedReleases(
217+ >>> result = breezy_autotest.getPublishedSources(
218 ... 'cnews', include_pending=True)
219 >>> soyuz_helper.checkPubList(all_main_pubs, result)
220 True
221@@ -88,7 +89,7 @@
222 ... pub_main_updates_pending,
223 ... ]
224
225- >>> result = breezy_autotest.getPublishedReleases(
226+ >>> result = breezy_autotest.getPublishedSources(
227 ... 'cnews', include_pending=True,
228 ... pocket=PackagePublishingPocket.UPDATES)
229
230@@ -107,7 +108,7 @@
231 ... non_release_main_pubs, key=operator.attrgetter('id'),
232 ... reverse=True)
233
234- >>> result = breezy_autotest.getPublishedReleases(
235+ >>> result = breezy_autotest.getPublishedSources(
236 ... 'cnews', include_pending=True,
237 ... exclude_pocket=PackagePublishingPocket.RELEASE)
238
239@@ -127,7 +128,7 @@
240 >>> all_ppa_pubs = sorted(
241 ... all_ppa_pubs, key=operator.attrgetter('id'), reverse=True)
242
243- >>> result = breezy_autotest.getPublishedReleases(
244+ >>> result = breezy_autotest.getPublishedSources(
245 ... 'cnews', include_pending=True, archive=cprov_archive)
246 >>> soyuz_helper.checkPubList(all_ppa_pubs, result)
247 True
248
249=== modified file 'lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py'
250--- lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-08-23 13:41:04 +0000
251+++ lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-08-26 06:32:47 +0000
252@@ -93,9 +93,11 @@
253
254 def assertDistroSeriesInitialisedCorrectly(self, foobuntu):
255 # Check that 'pmount' has been copied correctly
256- hoary_pmount_pubs = self.hoary.getPublishedReleases('pmount')
257- foobuntu_pmount_pubs = foobuntu.getPublishedReleases('pmount')
258- self.assertEqual(len(hoary_pmount_pubs), len(foobuntu_pmount_pubs))
259+ hoary_pmount_pubs = self.hoary.getPublishedSources('pmount')
260+ foobuntu_pmount_pubs = foobuntu.getPublishedSources('pmount')
261+ self.assertEqual(
262+ hoary_pmount_pubs.count(),
263+ foobuntu_pmount_pubs.count())
264 hoary_i386_pmount_pubs = self.hoary['i386'].getReleasedPackages(
265 'pmount')
266 foobuntu_i386_pmount_pubs = foobuntu['i386'].getReleasedPackages(
267@@ -144,7 +146,7 @@
268 foobuntu = self._create_distroseries(self.hoary)
269 self._set_pending_to_failed(self.hoary)
270 transaction.commit()
271- ids = InitialiseDistroSeries(foobuntu, ('i386',))
272+ ids = InitialiseDistroSeries(foobuntu, ('i386', ))
273 ids.check()
274 ids.initialise()
275 self.assertDistroSeriesInitialisedCorrectly(foobuntu)
276
277=== modified file 'scripts/ftpmaster-tools/remove-package.py'
278--- scripts/ftpmaster-tools/remove-package.py 2010-04-27 19:48:39 +0000
279+++ scripts/ftpmaster-tools/remove-package.py 2010-08-26 06:32:47 +0000
280@@ -353,7 +353,7 @@
281 to_remove.append(d)
282
283 if not Options.binaryonly:
284- for spp in distro_series.getPublishedReleases(removal):
285+ for spp in distro_series.getPublishedSources(removal):
286 package = spp.sourcepackagerelease.sourcepackagename.name
287 version = spp.sourcepackagerelease.version
288 if (Options.component and
289
290=== modified file 'scripts/ftpmaster-tools/sync-source.py'
291--- scripts/ftpmaster-tools/sync-source.py 2010-07-02 14:56:45 +0000
292+++ scripts/ftpmaster-tools/sync-source.py 2010-08-26 06:32:47 +0000
293@@ -379,7 +379,7 @@
294 Each element of the returned tuple is a list of lines (with trailing
295 whitespace stripped).
296 """
297- # XXX JRV 20100211: Copied from deb822.py in python-debian. When
298+ # XXX JRV 20100211: Copied from deb822.py in python-debian. When
299 # Launchpad switches to Lucid this copy should be removed.
300 # bug=520508
301
302@@ -446,11 +446,11 @@
303 if signing_rules.startswith("must be signed"):
304 dsc_file.seek(0)
305 # XXX JRV 20100211: When Launchpad starts depending on Lucid,
306- # use dsc.split_gpg_and_payload() instead.
307+ # use dsc.split_gpg_and_payload() instead.
308 # bug=520508
309 (gpg_pre, payload, gpg_post) = split_gpg_and_payload(dsc_file)
310 if gpg_pre == [] and gpg_post == []:
311- dak_utils.fubar("signature required for %s but not present"
312+ dak_utils.fubar("signature required for %s but not present"
313 % dsc_filename)
314 if signing_rules == "must be signed and valid":
315 if (gpg_pre[0] != "-----BEGIN PGP SIGNED MESSAGE-----" or
316@@ -523,7 +523,7 @@
317 else:
318 spp = []
319 for package in arguments:
320- spp.extend(distro_series.getPublishedReleases(package))
321+ spp.extend(distro_series.getPublishedSources(package))
322
323 for sp in spp:
324 component = sp.component.name