launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #20517
[Merge] lp:~cjwatson/launchpad/update-pkgcache-on-publish into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/update-pkgcache-on-publish into lp:launchpad.
Commit message:
Update DistributionSourcePackageCache when creating a new source publication.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/update-pkgcache-on-publish/+merge/295929
Update DistributionSourcePackageCache when creating a new source publication.
I made https://code.launchpad.net/~cjwatson/launchpad/sspb-cache/+merge/295852 declare this as a prerequisite, but apparently forgot to propose it in its own right. Go me.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/update-pkgcache-on-publish into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2016-05-17 13:35:03 +0000
+++ database/schema/security.cfg 2016-05-27 10:33:25 +0000
@@ -870,6 +870,7 @@
public.distribution = SELECT
public.distributionjob = SELECT, INSERT
public.distributionsourcepackage = SELECT, INSERT
+public.distributionsourcepackagecache = SELECT, INSERT, UPDATE, DELETE
public.distroseriesparent = SELECT
public.packagecopyjob = SELECT, INSERT
public.packagediff = SELECT, INSERT, UPDATE
@@ -912,6 +913,7 @@
public.cve = SELECT, INSERT
public.distributionjob = SELECT, INSERT, DELETE
public.distributionsourcepackage = SELECT, INSERT, UPDATE
+public.distributionsourcepackagecache = SELECT, INSERT, UPDATE, DELETE
public.distroseriesdifference = SELECT
public.distroseriesparent = SELECT, INSERT, UPDATE
public.flatpackagesetinclusion = SELECT, INSERT, UPDATE, DELETE
@@ -1055,6 +1057,7 @@
public.distribution = SELECT
public.distributionjob = SELECT, INSERT, UPDATE
public.distributionsourcepackage = SELECT, INSERT
+public.distributionsourcepackagecache = SELECT, INSERT, UPDATE
public.distroarchseries = SELECT, INSERT
public.distroseries = SELECT, UPDATE
public.distroseriesdifference = SELECT, INSERT, UPDATE
@@ -1109,6 +1112,7 @@
public.distribution = SELECT
public.distributionjob = SELECT, INSERT, UPDATE
public.distributionsourcepackage = SELECT, INSERT, UPDATE
+public.distributionsourcepackagecache = SELECT, INSERT, UPDATE
public.distroarchseries = SELECT, INSERT
public.distroseries = SELECT, UPDATE
public.distroseriesdifference = SELECT
@@ -1210,6 +1214,7 @@
public.componentselection = SELECT, INSERT, UPDATE
public.country = SELECT, INSERT, UPDATE
public.distribution = SELECT, INSERT, UPDATE
+public.distributionsourcepackagecache = SELECT, INSERT, UPDATE, DELETE
public.distroarchseries = SELECT, INSERT, UPDATE
public.distroseries = SELECT, INSERT, UPDATE
public.emailaddress = SELECT, INSERT, UPDATE
@@ -1383,6 +1388,7 @@
public.distribution = SELECT, UPDATE
public.distributionjob = SELECT, INSERT
public.distributionsourcepackage = SELECT, INSERT, UPDATE
+public.distributionsourcepackagecache = SELECT, INSERT, UPDATE
public.distroarchseries = SELECT
public.distroseries = SELECT, UPDATE
public.distroseriesparent = SELECT
@@ -1498,6 +1504,7 @@
public.distribution = SELECT, UPDATE
public.distributionjob = SELECT, INSERT
public.distributionsourcepackage = SELECT, INSERT, UPDATE
+public.distributionsourcepackagecache = SELECT, INSERT, UPDATE
public.distroarchseries = SELECT
public.distroseries = SELECT
public.distroseriesdifference = SELECT
=== modified file 'lib/lp/soyuz/model/distributionsourcepackagecache.py'
--- lib/lp/soyuz/model/distributionsourcepackagecache.py 2016-05-18 23:29:28 +0000
+++ lib/lp/soyuz/model/distributionsourcepackagecache.py 2016-05-27 10:33:25 +0000
@@ -119,13 +119,11 @@
cache.destroySelf()
@classmethod
- def _update(cls, distro, sourcepackagenames, archive, log):
+ def update(cls, distro, sourcepackagenames, archive, log=None):
"""Update the package cache for a given set of `ISourcePackageName`s.
Cached details include generated binarypackage names, summary
and description fti.
-
- 'log' is required and only prints debug level information.
"""
# Get the set of published sourcepackage releases.
@@ -142,7 +140,8 @@
PackagePublishingStatus.PUBLISHED))
).config(distinct=True).order_by(SourcePackageRelease.id))
if len(all_sprs) == 0:
- log.debug("No sources releases found.")
+ if log is not None:
+ log.debug("No sources releases found.")
return
spr_map = defaultdict(list)
@@ -201,7 +200,9 @@
binpkgsummaries = set()
binpkgdescriptions = set()
for spr_id, spr_version in sprs:
- log.debug("Considering source %s %s", spn.name, spr_version)
+ if log is not None:
+ log.debug(
+ "Considering source %s %s", spn.name, spr_version)
binpkgs = binaries_by_spr.get(spr_id, [])
for bpn, summary, description in binpkgs:
binpkgnames.add(bpn.name)
@@ -254,7 +255,7 @@
log.debug(
"Considering sources %s",
', '.join([spn.name for spn in chunk]))
- cls._update(distro, chunk, archive, log)
+ cls.update(distro, chunk, archive, log)
number_of_updates += len(chunk)
log.debug("Committing")
ztm.commit()
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2015-11-08 01:09:46 +0000
+++ lib/lp/soyuz/model/publishing.py 2016-05-27 10:33:25 +0000
@@ -1264,9 +1264,14 @@
ancestor=None, create_dsd_job=True,
creator=None, sponsor=None, packageupload=None):
"""See `IPublishingSet`."""
- # Avoid circular import.
+ # Circular imports.
from lp.registry.model.distributionsourcepackage import (
- DistributionSourcePackage)
+ DistributionSourcePackage,
+ )
+ from lp.soyuz.model.distributionsourcepackagecache import (
+ DistributionSourcePackageCache,
+ )
+
if distroseries.distribution != archive.distribution:
raise AssertionError(
"Series distribution %s doesn't match archive distribution %s."
@@ -1294,6 +1299,11 @@
distroseries, sourcepackagerelease.sourcepackagename, pocket)
Store.of(sourcepackagerelease).flush()
del get_property_cache(sourcepackagerelease).published_archives
+
+ DistributionSourcePackageCache.update(
+ distroseries.distribution,
+ [sourcepackagerelease.sourcepackagename], archive)
+
return pub
def getBuildsForSourceIds(self, source_publication_ids, archive=None,
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2016-05-14 10:17:36 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2016-05-27 10:33:25 +0000
@@ -906,6 +906,19 @@
super(TestPublishingSetLite, self).setUp()
self.person = self.factory.makePerson()
+ def test_newSourcePublication_updates_cache(self):
+ ubuntutest = getUtility(IDistributionSet)["ubuntutest"]
+ breezy_autotest = ubuntutest["breezy-autotest"]
+ spn = self.factory.makeSourcePackageName()
+ self.assertEqual(0, ubuntutest.searchSourcePackages(spn.name).count())
+ spr = self.factory.makeSourcePackageRelease(
+ archive=ubuntutest.main_archive, sourcepackagename=spn,
+ distroseries=breezy_autotest, creator=self.person)
+ getUtility(IPublishingSet).newSourcePublication(
+ ubuntutest.main_archive, spr, breezy_autotest, spr.component,
+ spr.section, self.factory.getAnyPocket())
+ self.assertEqual(1, ubuntutest.searchSourcePackages(spn.name).count())
+
def test_requestDeletion_marks_SPPHs_deleted(self):
spph = self.factory.makeSourcePackagePublishingHistory()
getUtility(IPublishingSet).requestDeletion([spph], self.person)
Follow ups