launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00757
lp:~michael.nelson/launchpad/remove-shortlist-getPublishedReleases into lp:launchpad/devel
Michael Nelson has proposed merging lp:~michael.nelson/launchpad/remove-shortlist-getPublishedReleases into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
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.
--
https://code.launchpad.net/~michael.nelson/launchpad/remove-shortlist-getPublishedReleases/+merge/33645
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~michael.nelson/launchpad/remove-shortlist-getPublishedReleases into lp:launchpad/devel.
=== modified file 'lib/lp/archiveuploader/nascentupload.py'
--- lib/lp/archiveuploader/nascentupload.py 2010-08-24 08:43:51 +0000
+++ lib/lp/archiveuploader/nascentupload.py 2010-08-25 14:25:57 +0000
@@ -589,7 +589,7 @@
archive = self.policy.archive
else:
archive = None
- candidates = self.policy.distroseries.getPublishedReleases(
+ candidates = self.policy.distroseries.getPublishedSources(
source_name, include_pending=True, pocket=pocket,
archive=archive)
if candidates:
=== modified file 'lib/lp/archiveuploader/nascentuploadfile.py'
--- lib/lp/archiveuploader/nascentuploadfile.py 2010-08-20 20:31:18 +0000
+++ lib/lp/archiveuploader/nascentuploadfile.py 2010-08-25 14:25:57 +0000
@@ -743,7 +743,7 @@
in DB yet (see verifySourcepackagerelease).
"""
distroseries = self.policy.distroseries
- spphs = distroseries.getPublishedReleases(
+ spphs = distroseries.getPublishedSources(
self.source_name, version=self.source_version,
include_pending=True, archive=self.policy.archive)
=== modified file 'lib/lp/registry/browser/distributionsourcepackage.py'
--- lib/lp/registry/browser/distributionsourcepackage.py 2010-08-20 20:31:18 +0000
+++ lib/lp/registry/browser/distributionsourcepackage.py 2010-08-25 14:25:57 +0000
@@ -36,6 +36,7 @@
redirection,
StandardLaunchpadFacets,
)
+from canonical.launchpad.helpers import shortlist
from canonical.launchpad.webapp.breadcrumb import Breadcrumb
from canonical.launchpad.webapp.menu import (
ApplicationMenu,
@@ -400,10 +401,10 @@
:param sourcepackage: ISourcePackage
"""
- publications = sourcepackage.distroseries.getPublishedReleases(
+ publications = sourcepackage.distroseries.getPublishedSources(
sourcepackage.sourcepackagename)
pocket_dict = {}
- for pub in publications:
+ for pub in shortlist(publications):
version = pub.source_package_version
pocket_dict.setdefault(version, []).append(pub)
return pocket_dict
=== modified file 'lib/lp/registry/doc/distroseries.txt'
--- lib/lp/registry/doc/distroseries.txt 2010-08-13 06:08:36 +0000
+++ lib/lp/registry/doc/distroseries.txt 2010-08-25 14:25:57 +0000
@@ -127,10 +127,10 @@
Warty (4.10)
-Published releases
-------------------
+Published sources
+-----------------
-DistroSeries.getPublishedReleases:
+DistroSeries.getPublishedSources:
>>> from lp.registry.model.distroseries import DistroSeries
>>> from lp.registry.model.sourcepackagename import SourcePackageName
@@ -138,27 +138,27 @@
Passing a ISourcePackageName as argument:
- >>> prs = warty2.getPublishedReleases(
+ >>> prs = warty2.getPublishedSources(
... SourcePackageName.byName('mozilla-firefox'))
- >>> print len(prs)
+ >>> print prs.count()
1
>>> print prs[0].sourcepackagerelease.sourcepackagename.name
mozilla-firefox
Passing a string name:
- >>> print len(warty2.getPublishedReleases('mozilla-firefox'))
+ >>> print warty2.getPublishedSources('mozilla-firefox').count()
1
Including pending publication records in the result:
- >>> print len(warty2.getPublishedReleases('mozilla-firefox',
- ... include_pending=True))
+ >>> print warty2.getPublishedSources('mozilla-firefox',
+ ... include_pending=True).count()
2
Not found as empty list:
- >>> print len(warty2.getPublishedReleases('nosuchpackage'))
+ >>> print warty2.getPublishedSources('nosuchpackage').count()
0
See distroseries-publishing-lookups.txt for more information.
@@ -317,9 +317,9 @@
... '99.2',hoary, hoary.owner)
>>> ids = InitialiseDistroSeries(humpy)
>>> ids.initialise()
- >>> len(hoary.getPublishedReleases('pmount'))
+ >>> hoary.getPublishedSources('pmount').count()
1
- >>> len(humpy.getPublishedReleases('pmount'))
+ >>> humpy.getPublishedSources('pmount').count()
1
>>> len(hoary['i386'].getReleasedPackages('pmount'))
1
=== modified file 'lib/lp/registry/interfaces/distroseries.py'
--- lib/lp/registry/interfaces/distroseries.py 2010-08-20 20:31:18 +0000
+++ lib/lp/registry/interfaces/distroseries.py 2010-08-25 14:25:57 +0000
@@ -533,9 +533,9 @@
and the value is a `IDistroSeriesSourcePackageRelease`.
"""
- def getPublishedReleases(sourcepackage_or_name, pocket=None, version=None,
- include_pending=False, exclude_pocket=None,
- archive=None):
+ def getPublishedSources(sourcepackage_or_name, pocket=None, version=None,
+ include_pending=False, exclude_pocket=None,
+ archive=None):
"""Return the SourcePackagePublishingHistory(s)
Given a ISourcePackageName or name.
=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py 2010-08-23 09:10:10 +0000
+++ lib/lp/registry/model/distroseries.py 2010-08-25 14:25:57 +0000
@@ -29,7 +29,10 @@
Join,
SQL,
)
-from storm.store import Store
+from storm.store import (
+ EmptyResultSet,
+ Store,
+ )
from zope.component import getUtility
from zope.interface import implements
@@ -52,7 +55,6 @@
DecoratedResultSet,
)
from canonical.launchpad.database.librarian import LibraryFileAlias
-from canonical.launchpad.helpers import shortlist
from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
from canonical.launchpad.interfaces.lpstorm import IStore
from canonical.launchpad.mail import signed_message_from_string
@@ -963,7 +965,7 @@
return [SourcePackage(sourcepackagename=spn, distroseries=self) for
spn in result]
- def getPublishedReleases(self, sourcepackage_or_name, version=None,
+ def getPublishedSources(self, sourcepackage_or_name, version=None,
pocket=None, include_pending=False,
exclude_pocket=None, archive=None):
"""See `IDistroSeries`."""
@@ -979,7 +981,7 @@
spns = getUtility(ISourcePackageNameSet)
spn = spns.queryByName(sourcepackage_or_name)
if spn is None:
- return []
+ return EmptyResultSet()
queries = ["""
sourcepackagerelease=sourcepackagerelease.id AND
@@ -1011,7 +1013,7 @@
" AND ".join(queries), clauseTables = ['SourcePackageRelease'],
orderBy=['-id'])
- return shortlist(published)
+ return published
def isUnstable(self):
"""See `IDistroSeries`."""
=== modified file 'lib/lp/soyuz/doc/distroseries-publishing-lookups.txt'
--- lib/lp/soyuz/doc/distroseries-publishing-lookups.txt 2010-02-09 12:32:01 +0000
+++ lib/lp/soyuz/doc/distroseries-publishing-lookups.txt 2010-08-25 14:25:57 +0000
@@ -1,4 +1,5 @@
-= DistroSeries source publishing lookups =
+DistroSeries source publishing lookups
+======================================
IDistroSeries allows source publishing lookup via
getReleasedPackages method which returns a shortlist of
@@ -60,7 +61,7 @@
... all_published_main_pubs, key=operator.attrgetter('id'),
... reverse=True)
- >>> result = breezy_autotest.getPublishedReleases('cnews')
+ >>> result = breezy_autotest.getPublishedSources('cnews')
>>> soyuz_helper.checkPubList(all_published_main_pubs, result)
True
@@ -77,7 +78,7 @@
>>> all_main_pubs = sorted(
... all_main_pubs, key=operator.attrgetter('id'), reverse=True)
- >>> result = breezy_autotest.getPublishedReleases(
+ >>> result = breezy_autotest.getPublishedSources(
... 'cnews', include_pending=True)
>>> soyuz_helper.checkPubList(all_main_pubs, result)
True
@@ -88,7 +89,7 @@
... pub_main_updates_pending,
... ]
- >>> result = breezy_autotest.getPublishedReleases(
+ >>> result = breezy_autotest.getPublishedSources(
... 'cnews', include_pending=True,
... pocket=PackagePublishingPocket.UPDATES)
@@ -107,7 +108,7 @@
... non_release_main_pubs, key=operator.attrgetter('id'),
... reverse=True)
- >>> result = breezy_autotest.getPublishedReleases(
+ >>> result = breezy_autotest.getPublishedSources(
... 'cnews', include_pending=True,
... exclude_pocket=PackagePublishingPocket.RELEASE)
@@ -127,7 +128,7 @@
>>> all_ppa_pubs = sorted(
... all_ppa_pubs, key=operator.attrgetter('id'), reverse=True)
- >>> result = breezy_autotest.getPublishedReleases(
+ >>> result = breezy_autotest.getPublishedSources(
... 'cnews', include_pending=True, archive=cprov_archive)
>>> soyuz_helper.checkPubList(all_ppa_pubs, result)
True
=== modified file 'lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-08-23 13:41:04 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-08-25 14:25:57 +0000
@@ -93,9 +93,11 @@
def assertDistroSeriesInitialisedCorrectly(self, foobuntu):
# Check that 'pmount' has been copied correctly
- hoary_pmount_pubs = self.hoary.getPublishedReleases('pmount')
- foobuntu_pmount_pubs = foobuntu.getPublishedReleases('pmount')
- self.assertEqual(len(hoary_pmount_pubs), len(foobuntu_pmount_pubs))
+ hoary_pmount_pubs = self.hoary.getPublishedSources('pmount')
+ foobuntu_pmount_pubs = foobuntu.getPublishedSources('pmount')
+ self.assertEqual(
+ hoary_pmount_pubs.count(),
+ foobuntu_pmount_pubs.count())
hoary_i386_pmount_pubs = self.hoary['i386'].getReleasedPackages(
'pmount')
foobuntu_i386_pmount_pubs = foobuntu['i386'].getReleasedPackages(
@@ -144,7 +146,7 @@
foobuntu = self._create_distroseries(self.hoary)
self._set_pending_to_failed(self.hoary)
transaction.commit()
- ids = InitialiseDistroSeries(foobuntu, ('i386',))
+ ids = InitialiseDistroSeries(foobuntu, ('i386', ))
ids.check()
ids.initialise()
self.assertDistroSeriesInitialisedCorrectly(foobuntu)