← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/copy-packagesets-when-ifp into lp:launchpad/devel

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/copy-packagesets-when-ifp into lp:launchpad/devel with lp:~stevenk/launchpad/switch-ifp-to-unittests as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


This branch adds the ability to InitialiseDistroSeries to copy packagesets when initialising a child distroseries from the parent.

I've had a pre-implemenation call with Julian about this, who agreed my idea sounded sane.


-- 
https://code.launchpad.net/~stevenk/launchpad/copy-packagesets-when-ifp/+merge/32442
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/copy-packagesets-when-ifp into lp:launchpad/devel.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2010-08-10 05:49:16 +0000
+++ database/schema/security.cfg	2010-08-12 13:44:26 +0000
@@ -771,7 +771,7 @@
 public.gpgkey                                   = SELECT, INSERT, UPDATE
 public.packagecopyrequest                       = SELECT, INSERT, UPDATE
 public.packagediff                              = SELECT, INSERT, UPDATE
-public.packageset                               = SELECT
+public.packageset                               = SELECT, INSERT
 public.packagesetgroup                          = SELECT
 public.packagesetsources                        = SELECT, INSERT, UPDATE, DELETE
 public.packagesetinclusion                      = SELECT, INSERT, UPDATE, DELETE

=== modified file 'lib/lp/soyuz/scripts/initialise_distroseries.py'
--- lib/lp/soyuz/scripts/initialise_distroseries.py	2010-08-12 13:44:10 +0000
+++ lib/lp/soyuz/scripts/initialise_distroseries.py	2010-08-12 13:44:26 +0000
@@ -118,6 +118,7 @@
     def initialise(self):
         self._copy_architectures()
         self._copy_packages()
+        self._copy_packagesets()
 
     def _copy_architectures(self):
         self._store.execute("""
@@ -254,3 +255,13 @@
                         )
                     )
             """ % self.distroseries.id)
+
+    def _copy_packagesets(self):
+        """Copy packagesets from the parent distroseries."""
+        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))

=== modified file 'lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py	2010-08-12 13:44:10 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialise_distroseries.py	2010-08-12 13:44:26 +0000
@@ -13,6 +13,7 @@
 
 from lp.buildmaster.interfaces.buildbase import BuildStatus
 from lp.registry.interfaces.pocket import PackagePublishingPocket
+from lp.soyuz.interfaces.packageset import IPackagesetSet
 from lp.soyuz.interfaces.sourcepackageformat import SourcePackageFormat
 from lp.soyuz.scripts.initialise_distroseries import (
     InitialiseDistroSeries, InitialisationError)
@@ -165,6 +166,39 @@
             'i386 build of pmount 0.1-2 in ubuntutest foobuntu RELEASE',
             created_build.title)
 
+    def test_copying_packagesets(self):
+        # If a parent series has packagesets, we should copy them
+        test1 = getUtility(IPackagesetSet).new(
+            u'test1', u'test 1 packageset', self.hoary.owner,
+            distroseries=self.hoary)
+        test2 = getUtility(IPackagesetSet).new(
+            u'test2', u'test 2 packageset', self.hoary.owner,
+            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()
+        # We can fetch the copied sets from foobuntu
+        foobuntu_test1 = getUtility(IPackagesetSet).getByName(
+            u'test1', distroseries=foobuntu)
+        foobuntu_test2 = getUtility(IPackagesetSet).getByName(
+            u'test2', distroseries=foobuntu)
+        foobuntu_test3 = getUtility(IPackagesetSet).getByName(
+            u'test3', distroseries=foobuntu)
+        # And we can see they are exact copies, with the related_set for the
+        # copies pointing to the packageset in the parent
+        self.assertEqual(test1.description, foobuntu_test1.description)
+        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)
+
     def test_script(self):
         # Do an end-to-end test using the command-line tool
         foobuntu = self._create_distroseries(self.hoary)