← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/distro-overlay2-bug-758908 into lp:launchpad/db-devel

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/distro-overlay2-bug-758908 into lp:launchpad/db-devel.

Requested reviews:
  Stuart Bishop (stub): db
  Robert Collins (lifeless)
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #758908 in Launchpad itself: "Allow a derived distribution to work as an overlay archive like a PPA works"
  https://bugs.launchpad.net/launchpad/+bug/758908

For more details, see:
https://code.launchpad.net/~rvb/launchpad/distro-overlay2-bug-758908/+merge/61089

This branch fixes the DistroSeriesParent object so that it might denote an overlay relashionship (the derived series will be an overlay over the parent).

This branch is only the db part and thus targets db-devel.

= Tests =
./bin/test -cvv test_distroseriesparent test_properties
./bin/test -cvv test_distroseriesparent test_properties_overlay

= Q/A =
None.
-- 
https://code.launchpad.net/~rvb/launchpad/distro-overlay2-bug-758908/+merge/61089
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/distro-overlay2-bug-758908 into lp:launchpad/db-devel.
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql	2011-05-11 10:32:15 +0000
+++ database/schema/comments.sql	2011-05-16 10:21:05 +0000
@@ -589,6 +589,9 @@
 COMMENT ON COLUMN DistroSeriesParent.derived_series is 'The derived distroseries';
 COMMENT ON COLUMN DistroSeriesParent.parent_series is 'The parent distroseries';
 COMMENT ON COLUMN DistroSeriesParent.initialized is 'Whether or not the derived series was initialized by copying packages from the parent.';
+COMMENT ON COLUMN DistroSeriesParent.is_overlay is 'Whether or not the derived series is an overlay over the parent series.';
+COMMENT ON COLUMN DistroSeriesParent.pocket is 'The pocket for this overlay.';
+COMMENT ON COLUMN DistroSeriesParent.component is 'The component for this overlay.';
 
 -- DistroSeriesPackageCache
 

=== added file 'database/schema/patch-2208-99-0.sql'
--- database/schema/patch-2208-99-0.sql	1970-01-01 00:00:00 +0000
+++ database/schema/patch-2208-99-0.sql	2011-05-16 10:21:05 +0000
@@ -0,0 +1,18 @@
+-- Copyright 2011 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+-- Add a column to identifie a DSP as an overlay.
+ALTER TABLE DistroSeriesParent
+    ADD COLUMN is_overlay BOOLEAN NOT NULL DEFAULT FALSE;
+
+-- Add a reference to a component.
+ALTER TABLE DistroSeriesParent
+    ADD COLUMN component INTEGER REFERENCES Component;
+
+-- Add a 'reference' to a pocket.
+ALTER TABLE DistroSeriesParent
+    ADD COLUMN pocket INTEGER;
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 99, 0);

=== modified file 'lib/lp/registry/interfaces/distroseriesparent.py'
--- lib/lp/registry/interfaces/distroseriesparent.py	2011-04-14 17:11:07 +0000
+++ lib/lp/registry/interfaces/distroseriesparent.py	2011-05-16 10:21:05 +0000
@@ -15,12 +15,14 @@
 from lazr.restful.fields import Reference
 from zope.interface import Interface
 from zope.schema import (
+    Bool,
+    Choice,
     Int,
-    Bool,
     )
 
 from canonical.launchpad import _
 from lp.registry.interfaces.distroseries import IDistroSeries
+from lp.registry.interfaces.pocket import PackagePublishingPocket
 
 
 class IDistroSeriesParent(Interface):
@@ -42,11 +44,24 @@
             "Whether or not the derived_series has been populated with "
             "packages from its parent_series."))
 
+    is_overlay = Bool(
+        title=_("Is this relationship an overlay?"), required=True,
+        default=False)
+
+    pocket = Choice(
+        title=_("The pocket for this overlay"), required=False,
+        vocabulary=PackagePublishingPocket)
+
+    component = Choice(
+        title=_("The component for this overlay"), required=False,
+        vocabulary='Component')
+
 
 class IDistroSeriesParentSet(Interface):
     """`DistroSeriesParentSet` interface."""
 
-    def new(derived_series, parent_series, initialized):
+    def new(derived_series, parent_series, initialized, is_overlay=False,
+            pocket=None, component=None):
         """Create a new `DistroSeriesParent`."""
 
     def getByDerivedSeries(derived_series):

=== modified file 'lib/lp/registry/model/distroseriesparent.py'
--- lib/lp/registry/model/distroseriesparent.py	2011-04-14 17:11:07 +0000
+++ lib/lp/registry/model/distroseriesparent.py	2011-05-16 10:21:05 +0000
@@ -11,13 +11,14 @@
     ]
 
 from storm.locals import (
+    Bool,
     Int,
     Reference,
     Storm,
-    Bool,
     )
 from zope.interface import implements
 
+from canonical.database.enumcol import EnumCol
 from canonical.launchpad.interfaces.lpstorm import (
     IMasterStore,
     IStore,
@@ -26,6 +27,7 @@
     IDistroSeriesParent,
     IDistroSeriesParentSet,
     )
+from lp.registry.interfaces.pocket import PackagePublishingPocket
 
 
 class DistroSeriesParent(Storm):
@@ -43,19 +45,32 @@
 
     initialized = Bool(allow_none=False)
 
+    is_overlay = Bool(allow_none=False, default=False)
+
+    pocket = EnumCol(
+        dbName='pocket', notNull=False,
+        schema=PackagePublishingPocket)
+
+    component_id = Int(name='component', allow_none=True)
+    component = Reference(component_id, 'Component.id')
+
 
 class DistroSeriesParentSet:
     """See `IDistroSeriesParentSet`."""
     implements(IDistroSeriesParentSet)
     title = "Cross reference of parent and derived distroseries."
 
-    def new(self, derived_series, parent_series, initialized):
+    def new(self, derived_series, parent_series, initialized,
+            is_overlay=False, pocket=None, component=None):
         """Make and return a new `DistroSeriesParent`."""
         store = IMasterStore(DistroSeriesParent)
         dsp = DistroSeriesParent()
         dsp.derived_series = derived_series
         dsp.parent_series = parent_series
         dsp.initialized = initialized
+        dsp.is_overlay = is_overlay
+        dsp.pocket = pocket
+        dsp.component = component
         store.add(dsp)
         return dsp
 

=== modified file 'lib/lp/registry/tests/test_distroseriesparent.py'
--- lib/lp/registry/tests/test_distroseriesparent.py	2011-04-18 12:18:26 +0000
+++ lib/lp/registry/tests/test_distroseriesparent.py	2011-05-16 10:21:05 +0000
@@ -9,7 +9,6 @@
     Equals,
     MatchesStructure,
     )
-
 from zope.component import getUtility
 from zope.interface.verify import verifyObject
 from zope.security.interfaces import Unauthorized
@@ -23,11 +22,13 @@
     IDistroSeriesParent,
     IDistroSeriesParentSet,
     )
+from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.testing import (
     person_logged_in,
     TestCaseWithFactory,
     )
 from lp.testing.sampledata import LAUNCHPAD_ADMIN
+from lp.soyuz.interfaces.component import IComponentSet
 
 
 class TestDistroSeriesParent(TestCaseWithFactory):
@@ -55,7 +56,35 @@
             MatchesStructure(
                 derived_series=Equals(derived_series),
                 parent_series=Equals(parent_series),
-                initialized=Equals(True)
+                initialized=Equals(True),
+                is_overlay=Equals(False),
+                component=Equals(None),
+                pocket=Equals(None),
+                ))
+
+    def test_properties_overlay(self):
+        # Test the model properties if the DSP represents an overlay.
+        parent_series = self.factory.makeDistroSeries()
+        derived_series = self.factory.makeDistroSeries()
+        main_component = getUtility(IComponentSet).ensure('main')
+        dsp = self.factory.makeDistroSeriesParent(
+            derived_series=derived_series,
+            parent_series=parent_series,
+            initialized=True,
+            is_overlay=True,
+            component=main_component,
+            pocket=PackagePublishingPocket.SECURITY,
+            )
+
+        self.assertThat(
+            dsp,
+            MatchesStructure(
+                derived_series=Equals(derived_series),
+                parent_series=Equals(parent_series),
+                initialized=Equals(True),
+                is_overlay=Equals(True),
+                component=Equals(main_component),
+                pocket=Equals(PackagePublishingPocket.SECURITY),
                 ))
 
     def test_getByDerivedSeries(self):
@@ -78,7 +107,7 @@
     def test_getByParentSeries(self):
         parent_series = self.factory.makeDistroSeries()
         derived_series = self.factory.makeDistroSeries()
-        dsp = self.factory.makeDistroSeriesParent(
+        self.factory.makeDistroSeriesParent(
             derived_series, parent_series)
         results = getUtility(IDistroSeriesParentSet).getByParentSeries(
             parent_series)

=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py	2011-05-11 16:07:09 +0000
+++ lib/lp/testing/factory.py	2011-05-16 10:21:05 +0000
@@ -2454,13 +2454,15 @@
             distro_series_difference, owner, comment)
 
     def makeDistroSeriesParent(self, derived_series=None, parent_series=None,
-                               initialized=False):
+                               initialized=False, is_overlay=False,
+                               pocket=None, component=None):
         if parent_series is None:
             parent_series = self.makeDistroSeries()
         if derived_series is None:
             derived_series = self.makeDistroSeries()
         return getUtility(IDistroSeriesParentSet).new(
-            derived_series, parent_series, initialized)
+            derived_series, parent_series, initialized, is_overlay, pocket,
+            component)
 
     def makeDistroArchSeries(self, distroseries=None,
                              architecturetag=None, processorfamily=None,