launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00667
[Merge] lp:~stevenk/launchpad/really-copy-packagesets-when-ifp into lp:launchpad/devel
Steve Kowalik has proposed merging lp:~stevenk/launchpad/really-copy-packagesets-when-ifp into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
This branch changes the packageset copying code in InitialiseDistroSeries to also copy the contents of the packageset, as well as any archivepermission associated with the packageset. It also extends the tests to cover the cases added.
Lint has been corrected, and to test: bin/test -vvt test_initialise_distroseries
--
https://code.launchpad.net/~stevenk/launchpad/really-copy-packagesets-when-ifp/+merge/33089
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/really-copy-packagesets-when-ifp into lp:launchpad/devel.
=== modified file 'lib/lp/soyuz/scripts/initialise_distroseries.py'
--- lib/lp/soyuz/scripts/initialise_distroseries.py 2010-08-12 11:17:32 +0000
+++ lib/lp/soyuz/scripts/initialise_distroseries.py 2010-08-19 09:28:54 +0000
@@ -21,6 +21,7 @@
from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet
from lp.soyuz.interfaces.queue import PackageUploadStatus
from lp.soyuz.model.packagecloner import clone_packages
+from lp.soyuz.model.packageset import Packageset
class InitialisationError(Exception):
@@ -258,10 +259,28 @@
def _copy_packagesets(self):
"""Copy packagesets from the parent distroseries."""
- self._store.execute("""
+ packagesets = self._store.find(Packageset, distroseries=self.parent)
+ for parent_ps in packagesets:
+ self._store.execute("""
INSERT INTO Packageset
(distroseries, owner, name, description, packagesetgroup)
SELECT %s, %s, name, description, packagesetgroup
- FROM Packageset WHERE distroseries = %s
- """ % sqlvalues(
- self.distroseries, self.distroseries.owner, self.parent))
+ FROM Packageset WHERE id = %s
+ """ % sqlvalues(
+ self.distroseries, self.distroseries.owner, parent_ps.id))
+ child_ps = self._store.find(
+ Packageset, distroseries=self.distroseries,
+ name=parent_ps.name).one()
+ self._store.execute("""
+ INSERT INTO Packagesetsources
+ (packageset, sourcepackagename)
+ SELECT %s, sourcepackagename FROM Packagesetsources
+ WHERE packageset = %s
+ """ % sqlvalues(child_ps.id, parent_ps.id))
+ self._store.execute("""
+ INSERT INTO Archivepermission
+ (person, permission, archive, packageset, explicit)
+ SELECT person, permission, %s, %s, explicit
+ FROM Archivepermission WHERE packageset = %s
+ """ % sqlvalues(
+ self.distroseries.main_archive, child_ps.id, parent_ps.id))
=== modified file 'lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-08-12 12:48:17 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py 2010-08-19 09:28:54 +0000
@@ -13,6 +13,7 @@
from lp.buildmaster.interfaces.buildbase import BuildStatus
from lp.registry.interfaces.pocket import PackagePublishingPocket
+from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
from lp.soyuz.interfaces.packageset import IPackagesetSet
from lp.soyuz.interfaces.sourcepackageformat import SourcePackageFormat
from lp.soyuz.scripts.initialise_distroseries import (
@@ -79,7 +80,7 @@
self.ubuntu['breezy-autotest'])
ids = InitialiseDistroSeries(foobuntu)
self.assertRaisesWithContent(
- InitialisationError,"Parent series queues are not empty.",
+ InitialisationError, "Parent series queues are not empty.",
ids.check)
def assertDistroSeriesInitialisedCorrectly(self, foobuntu):
@@ -168,6 +169,7 @@
def test_copying_packagesets(self):
# If a parent series has packagesets, we should copy them
+ joe = self.factory.makePerson(name='joe')
test1 = getUtility(IPackagesetSet).new(
u'test1', u'test 1 packageset', self.hoary.owner,
distroseries=self.hoary)
@@ -176,13 +178,11 @@
distroseries=self.hoary)
test3 = getUtility(IPackagesetSet).new(
u'test3', u'test 3 packageset', self.hoary.owner,
- distroseries=self.hoary)
- foobuntu = self._create_distroseries(self.hoary)
- self._set_pending_to_failed(self.hoary)
- transaction.commit()
- ids = InitialiseDistroSeries(foobuntu)
- ids.check()
- ids.initialise()
+ distroseries=self.hoary, related_set=test2)
+ test1.addSources('pmount')
+ getUtility(IArchivePermissionSet).newPackagesetUploader(
+ self.hoary.main_archive, joe, test1)
+ foobuntu = self._full_initialise()
# We can fetch the copied sets from foobuntu
foobuntu_test1 = getUtility(IPackagesetSet).getByName(
u'test1', distroseries=foobuntu)
@@ -196,8 +196,25 @@
self.assertEqual(test2.description, foobuntu_test2.description)
self.assertEqual(test3.description, foobuntu_test3.description)
self.assertEqual(foobuntu_test1.relatedSets().one(), test1)
- self.assertEqual(foobuntu_test2.relatedSets().one(), test2)
- self.assertEqual(foobuntu_test3.relatedSets().one(), test3)
+ self.assertEqual(
+ list(foobuntu_test2.relatedSets()),
+ [test2, test3, foobuntu_test3])
+ self.assertEqual(
+ list(foobuntu_test3.relatedSets()),
+ [test2, foobuntu_test2, test3])
+ # The contents of the packagesets will have been copied
+ foobuntu_srcs = foobuntu_test1.getSourcesIncluded(
+ direct_inclusion=True)
+ hoary_srcs = test1.getSourcesIncluded(direct_inclusion=True)
+ self.assertEqual(foobuntu_srcs, hoary_srcs)
+ # joe can also upload to the new distroseries
+ self.assertTrue(
+ getUtility(IArchivePermissionSet).isSourceUploadAllowed(
+ self.hoary.main_archive, 'pmount', joe,
+ distroseries=self.hoary))
+ self.assertTrue(
+ getUtility(IArchivePermissionSet).isSourceUploadAllowed(
+ foobuntu.main_archive, 'pmount', joe, distroseries=foobuntu))
def test_script(self):
# Do an end-to-end test using the command-line tool
Follow ups