launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02077
[Merge] lp:~stevenk/launchpad/db-spph-ancestry into lp:launchpad/db-devel
Steve Kowalik has proposed merging lp:~stevenk/launchpad/db-spph-ancestry into lp:launchpad/db-devel.
Requested reviews:
Stuart Bishop (stub): db
Launchpad code reviewers (launchpad-reviewers)
--
https://code.launchpad.net/~stevenk/launchpad/db-spph-ancestry/+merge/41943
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/db-spph-ancestry into lp:launchpad/db-devel.
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql 2010-11-27 07:17:00 +0000
+++ database/schema/comments.sql 2010-12-01 06:30:23 +0000
@@ -1780,7 +1780,8 @@
COMMENT ON COLUMN SourcePackagePublishingHistory.pocket IS 'The pocket into which this record is published. The RELEASE pocket (zero) provides behaviour as normal. Other pockets may append things to the distroseries name such as the UPDATES pocket (-updates), the SECURITY pocket (-security) and the PROPOSED pocket (-proposed)';
COMMENT ON COLUMN SourcePackagePublishingHistory.removed_by IS 'Person responsible for the removal.';
COMMENT ON COLUMN SourcePackagePublishingHistory.removal_comment IS 'Reason why the publication was removed.';
-COMMENT ON COLUMN SourcePackagePublishingHistory.archive IS 'The target archive for thi publishing record.';
+COMMENT ON COLUMN SourcePackagePublishingHistory.archive IS 'The target archive for this publishing record.';
+COMMENT ON COLUMN SourcePackagePublishingHistory.ancestor IS 'The source package record published immediately before this one.';
-- Packaging
COMMENT ON TABLE Packaging IS 'DO NOT JOIN THROUGH THIS TABLE. This is a set
=== 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 2010-12-01 06:30:23 +0000
@@ -0,0 +1,7 @@
+SET client_min_messages=ERROR;
+
+ALTER TABLE SourcePackagePublishingHistory
+ ADD COLUMN ancestor INTEGER REFERENCES SourcePackagePublishingHistory;
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 99, 0);
+
=== modified file 'lib/canonical/launchpad/interfaces/_schema_circular_imports.py'
--- lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2010-11-30 03:11:58 +0000
+++ lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2010-12-01 06:30:23 +0000
@@ -277,6 +277,9 @@
IBinaryPackagePublishingHistory, 'archive', IArchive)
patch_reference_property(
ISourcePackagePublishingHistory, 'archive', IArchive)
+patch_reference_property(
+ ISourcePackagePublishingHistory, 'ancestor',
+ ISourcePackagePublishingHistory)
# IArchive apocalypse.
patch_reference_property(IArchive, 'distribution', IDistribution)
=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
--- lib/lp/soyuz/interfaces/publishing.py 2010-11-10 04:25:52 +0000
+++ lib/lp/soyuz/interfaces/publishing.py 2010-12-01 06:30:23 +0000
@@ -458,6 +458,12 @@
"package that has been published in the main distribution series, "
"if one exists, or None.")
+ ancestor = Reference(
+ Interface, # Really ISourcePackagePublishingHistory
+ title=_('Ancestor'),
+ description=_('The previous release of this source package.'),
+ required=False, readonly=True)
+
# Really IBinaryPackagePublishingHistory, see below.
@operation_returns_collection_of(Interface)
@export_read_operation()
@@ -874,7 +880,7 @@
"""
def newSourcePublication(archive, sourcepackagerelease, distroseries,
- component, section, pocket):
+ component, section, pocket, ancestor):
"""Create a new `SourcePackagePublishingHistory`.
:param archive: An `IArchive`
@@ -883,6 +889,8 @@
:param component: An `IComponent`
:param section: An `ISection`
:param pocket: A `PackagePublishingPocket`
+ :param ancestor: A `ISourcePackagePublishingHistory` for the previous
+ version of this publishing record
datecreated will be UTC_NOW.
status will be PackagePublishingStatus.PENDING
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2010-11-15 16:25:05 +0000
+++ lib/lp/soyuz/model/publishing.py 2010-12-01 06:30:23 +0000
@@ -430,6 +430,9 @@
dbName="removed_by", foreignKey="Person",
storm_validator=validate_public_person, default=None)
removal_comment = StringCol(dbName="removal_comment", default=None)
+ ancestor = ForeignKey(
+ dbName="ancestor", foreignKey="SourcePackagePublishingHistory",
+ default=None)
@property
def package_creator(self):
@@ -1307,7 +1310,8 @@
return pub
def newSourcePublication(self, archive, sourcepackagerelease,
- distroseries, component, section, pocket):
+ distroseries, component, section, pocket,
+ ancestor=None):
"""See `IPublishingSet`."""
if archive.is_ppa:
# PPA component must always be 'main', so we override it
@@ -1321,7 +1325,8 @@
component=component,
section=section,
status=PackagePublishingStatus.PENDING,
- datecreated=UTC_NOW)
+ datecreated=UTC_NOW,
+ ancestor=ancestor)
# Import here to prevent import loop.
from lp.registry.model.distributionsourcepackage import (
DistributionSourcePackage)
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2010-10-06 11:46:51 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2010-12-01 06:30:23 +0000
@@ -23,8 +23,8 @@
from canonical.testing.layers import (
DatabaseFunctionalLayer,
LaunchpadZopelessLayer,
+ reconnect_stores,
)
-from canonical.testing.layers import reconnect_stores
from lp.app.errors import NotFoundError
from lp.archivepublisher.config import Config
from lp.archivepublisher.diskpool import DiskPool
@@ -57,7 +57,10 @@
BinaryPackagePublishingHistory,
SourcePackagePublishingHistory,
)
-from lp.testing import TestCaseWithFactory
+from lp.testing import (
+ login_as,
+ TestCaseWithFactory,
+ )
from lp.testing.factory import LaunchpadObjectFactory
from lp.testing.fakemethod import FakeMethod
@@ -1334,3 +1337,15 @@
series, bins[0].pocket, bins[0].archive)
self.checkOtherPublications(bins[0], bins)
self.checkOtherPublications(foreign_bins[0], foreign_bins)
+
+class TestSPPHModel(TestCaseWithFactory):
+ """Test parts of the SourcePackagePublishingHistory model."""
+
+ layer = LaunchpadZopelessLayer
+
+ def testAncestry(self):
+ """Ancestry can be traversed."""
+ ancestor = self.factory.makeSourcePackagePublishingHistory()
+ spph = self.factory.makeSourcePackagePublishingHistory(
+ ancestor=ancestor)
+ self.assertEquals(spph.ancestor.displayname, ancestor.displayname)
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-11-30 11:48:27 +0000
+++ lib/lp/testing/factory.py 2010-12-01 06:30:23 +0000
@@ -2998,6 +2998,7 @@
dsc_format='1.0',
dsc_binaries='foo-bin',
sourcepackagerelease=None,
+ ancestor=None,
):
"""Make a `SourcePackagePublishingHistory`."""
if distroseries is None:
@@ -3041,7 +3042,7 @@
spph = getUtility(IPublishingSet).newSourcePublication(
archive, sourcepackagerelease, distroseries,
sourcepackagerelease.component, sourcepackagerelease.section,
- pocket)
+ pocket, ancestor)
naked_spph = removeSecurityProxy(spph)
naked_spph.status = status
Follow ups