launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01365
[Merge] lp:~stevenk/launchpad/ids-limit-packagesets into lp:launchpad/devel
Steve Kowalik has proposed merging lp:~stevenk/launchpad/ids-limit-packagesets into lp:launchpad/devel with lp:~stevenk/launchpad/ids-no-more-sampledata as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
--
https://code.launchpad.net/~stevenk/launchpad/ids-limit-packagesets/+merge/37558
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/ids-limit-packagesets into lp:launchpad/devel.
=== modified file 'lib/lp/soyuz/interfaces/packagecloner.py'
--- lib/lp/soyuz/interfaces/packagecloner.py 2010-10-05 06:12:59 +0000
+++ lib/lp/soyuz/interfaces/packagecloner.py 2010-10-05 06:13:00 +0000
@@ -19,7 +19,7 @@
def clonePackages(
origin, destination, distroarchseries_list=None,
- proc_familes=None, always_create=False):
+ proc_familes=None, spns=None, always_create=False):
"""Copies the source packages from origin to destination as
well as the binary packages for the DistroArchSeries specified.
@@ -29,6 +29,7 @@
for the distroarchseries pairs specified (if any).
:param proc_familes: the processor families that builds will be
created for.
+ :param spns: the source packages which are to be copied.
:param always_create: if builds should always be created.
"""
=== modified file 'lib/lp/soyuz/model/packagecloner.py'
--- lib/lp/soyuz/model/packagecloner.py 2010-10-05 06:12:59 +0000
+++ lib/lp/soyuz/model/packagecloner.py 2010-10-05 06:13:00 +0000
@@ -61,7 +61,7 @@
implements(IPackageCloner)
def clonePackages(self, origin, destination, distroarchseries_list=None,
- proc_families=None, always_create=False):
+ proc_families=None, spns=None, always_create=False):
"""Copies packages from origin to destination package location.
Binary packages are only copied for the `DistroArchSeries` pairs
@@ -75,20 +75,23 @@
distroarchseries instances.
@param distroarchseries_list: the binary packages will be copied
for the distroarchseries pairs specified (if any).
- @param the processor families to create builds for.
+ @param proc_families: the processor families to create builds for.
+ @type proc_families: Iterable
+ @param spns: the sourcepackages to copy to the destination
+ @type spns: Iterable
@param always_create: if we should create builds for every source
package copied, useful if no binaries are to be copied.
@type always_create: Boolean
"""
# First clone the source packages.
- self._clone_source_packages(origin, destination)
+ self._clone_source_packages(origin, destination, spns)
# Are we also supposed to clone binary packages from origin to
# destination distroarchseries pairs?
if distroarchseries_list is not None:
for (origin_das, destination_das) in distroarchseries_list:
self._clone_binary_packages(
- origin, destination, origin_das, destination_das)
+ origin, destination, origin_das, destination_das, spns)
if proc_families is None:
proc_families = []
@@ -147,7 +150,7 @@
transaction.commit()
def _clone_binary_packages(self, origin, destination, origin_das,
- destination_das):
+ destination_das, spns=None):
"""Copy binary publishing data from origin to destination.
@type origin: PackageLocation
@@ -162,9 +165,11 @@
@type destination_das: DistroArchSeries
@param destination_das: the DistroArchSeries to which to copy
binary packages
+ @type spns: Iterable
+ @param spns: List of source packages to restrict the copy to
"""
store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
- store.execute('''
+ query = '''
INSERT INTO BinaryPackagePublishingHistory (
binarypackagerelease, distroarchseries, status,
component, section, priority, archive, datecreated,
@@ -182,7 +187,21 @@
destination.pocket, origin_das,
PackagePublishingStatus.PENDING,
PackagePublishingStatus.PUBLISHED,
- origin.pocket, origin.archive))
+ origin.pocket, origin.archive)
+
+ if spns and len(spns) > 0:
+ query += '''AND bpph.binarypackagerelease IN (
+ SELECT bpr.id
+ FROM BinaryPackageRelease AS bpr,
+ BinaryPackageBuild as bpb,
+ SourcePackageRelease as spr,
+ SourcePackageName as spn
+ WHERE bpb.id = bpr.build AND
+ bpb.source_package_release = spr.id
+ AND spr.sourcepackagename = spn.id
+ AND spn.name IN %s)''' % sqlvalues(spns)
+
+ store.execute(query)
def mergeCopy(self, origin, destination):
"""Please see `IPackageCloner`."""
@@ -377,7 +396,7 @@
" AND secsrc.component = %s" % quote(destination.component))
store.execute(pop_query)
- def _clone_source_packages(self, origin, destination):
+ def _clone_source_packages(self, origin, destination, spns):
"""Copy source publishing data from origin to destination.
@type origin: PackageLocation
@@ -386,6 +405,8 @@
@type destination: PackageLocation
@param destination: the location to which the data is
to be copied.
+ @type spns: Iterable
+ @param spns: List of source packages to restrict the copy to
"""
store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
query = '''
@@ -406,6 +427,14 @@
PackagePublishingStatus.PUBLISHED,
origin.pocket, origin.archive)
+ if spns and len(spns) > 0:
+ query += '''AND spph.sourcepackagerelease IN (
+ (SELECT spr.id
+ FROM SourcePackageRelease AS spr,
+ SourcePackageName AS spn
+ WHERE spr.sourcepackagename = spn.id
+ AND spn.name IN %s))''' % sqlvalues(spns)
+
if origin.packagesets:
query += '''AND spph.sourcepackagerelease IN
(SELECT spr.id
=== modified file 'lib/lp/soyuz/scripts/initialise_distroseries.py'
--- lib/lp/soyuz/scripts/initialise_distroseries.py 2010-10-05 06:12:59 +0000
+++ lib/lp/soyuz/scripts/initialise_distroseries.py 2010-10-05 06:13:00 +0000
@@ -59,10 +59,13 @@
in the initialisation of a derivative.
"""
- def __init__(self, distroseries, arches=(), rebuild=False):
+ def __init__(
+ self, distroseries, arches=(), packagesets=(), rebuild=False):
+
self.distroseries = distroseries
self.parent = self.distroseries.parent_series
self.arches = arches
+ self.packagesets = packagesets
self.rebuild = rebuild
self._store = IMasterStore(DistroSeries)
@@ -179,6 +182,13 @@
"""
archive_set = getUtility(IArchiveSet)
+ spns = []
+ if self.packagesets:
+ for pkgsetname in self.packagesets:
+ pkgset = getUtility(IPackagesetSet).getByName(
+ pkgsetname, distroseries=self.parent)
+ spns += list(pkgset.getSourcesIncluded())
+
for archive in self.parent.distribution.all_distro_archives:
if archive.purpose not in (
ArchivePurpose.PRIMARY, ArchivePurpose.DEBUG):
@@ -203,7 +213,7 @@
distroarchseries_list = ()
getUtility(IPackageCloner).clonePackages(
origin, destination, distroarchseries_list,
- proc_families, self.rebuild)
+ proc_families, spns, self.rebuild)
def _copy_component_section_and_format_selections(self):
"""Copy the section, component and format selections from the parent
@@ -281,6 +291,8 @@
parent_to_child = {}
# Create the packagesets, and any archivepermissions
for parent_ps in packagesets:
+ if self.packagesets and parent_ps.name not in self.packagesets:
+ continue
child_ps = getUtility(IPackagesetSet).new(
parent_ps.name, parent_ps.description,
self.distroseries.owner, distroseries=self.distroseries,
=== modified file 'lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-10-05 06:12:59 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-10-05 06:13:00 +0000
@@ -19,7 +19,10 @@
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.soyuz.enums import SourcePackageFormat
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
-from lp.soyuz.interfaces.packageset import IPackagesetSet
+from lp.soyuz.interfaces.packageset import (
+ IPackagesetSet,
+ NoSuchPackageSet,
+ )
from lp.soyuz.interfaces.publishing import PackagePublishingStatus
from lp.soyuz.interfaces.sourcepackageformat import (
ISourcePackageFormatSelectionSet,
@@ -155,9 +158,9 @@
child.isSourcePackageFormatPermitted(
SourcePackageFormat.FORMAT_1_0))
- def _full_initialise(self, arches=(), rebuild=False):
+ def _full_initialise(self, arches=(), packagesets=(), rebuild=False):
child = self.factory.makeDistroSeries(parent_series=self.parent)
- ids = InitialiseDistroSeries(child, arches, rebuild)
+ ids = InitialiseDistroSeries(child, arches, packagesets, rebuild)
ids.check()
ids.initialise()
return child
@@ -230,6 +233,33 @@
child.main_archive, 'udev', uploader,
distroseries=child))
+ def test_copy_limit_packagesets(self):
+ # If a parent series has packagesets, we can decide which ones we
+ # want to copy
+ test1 = getUtility(IPackagesetSet).new(
+ u'test1', u'test 1 packageset', self.parent.owner,
+ distroseries=self.parent)
+ test2 = getUtility(IPackagesetSet).new(
+ u'test2', u'test 2 packageset', self.parent.owner,
+ distroseries=self.parent)
+ packages = ('udev', 'chromium', 'libc6')
+ for pkg in packages:
+ test1.addSources(pkg)
+ child = self._full_initialise(packagesets=('test1',))
+ child_test1 = getUtility(IPackagesetSet).getByName(
+ u'test1', distroseries=child)
+ self.assertEqual(test1.description, child_test1.description)
+ self.assertRaises(
+ NoSuchPackageSet, getUtility(IPackagesetSet).getByName,
+ u'test2', distroseries=child)
+ parent_srcs = test1.getSourcesIncluded(direct_inclusion=True)
+ child_srcs = child_test1.getSourcesIncluded(
+ direct_inclusion=True)
+ self.assertEqual(parent_srcs, child_srcs)
+ child.updatePackageCount()
+ self.assertEqual(child.sourcecount, len(packages))
+ self.assertEqual(child.binarycount, 2) # Chromium is FTBFS
+
def test_rebuild_flag(self):
# No binaries will get copied if we specify rebuild=True
self.parent.updatePackageCount()
@@ -242,6 +272,35 @@
self.assertEqual(child.binarycount, 0)
self.assertEqual(builds.count(), self.parent.sourcecount)
+ def test_limit_packagesets_rebuild_and_one_das(self):
+ # We can limit the source packages copied, and only builds
+ # for the copied source will be created
+ test1 = getUtility(IPackagesetSet).new(
+ u'test1', u'test 1 packageset', self.parent.owner,
+ distroseries=self.parent)
+ test2 = getUtility(IPackagesetSet).new(
+ u'test2', u'test 2 packageset', self.parent.owner,
+ distroseries=self.parent)
+ packages = ('udev', 'chromium')
+ for pkg in packages:
+ test1.addSources(pkg)
+ self.factory.makeDistroArchSeries(distroseries=self.parent)
+ child = self._full_initialise(
+ arches=[self.parent_das.architecturetag],
+ packagesets=('test1',), rebuild=True)
+ child.updatePackageCount()
+ builds = child.getBuildRecords(
+ build_state=BuildStatus.NEEDSBUILD,
+ pocket=PackagePublishingPocket.RELEASE)
+ self.assertEqual(child.sourcecount, len(packages))
+ self.assertEqual(child.binarycount, 0)
+ self.assertEqual(builds.count(), len(packages))
+ das = list(IStore(DistroArchSeries).find(
+ DistroArchSeries, distroseries = child))
+ self.assertEqual(len(das), 1)
+ self.assertEqual(
+ das[0].architecturetag, self.parent_das.architecturetag)
+
def test_script(self):
# Do an end-to-end test using the command-line tool
uploader = self.factory.makePerson()
Follow ups