Merge ~cjwatson/launchpad:publish-by-null-datepublished into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: a96d92b6620778489bd90c445d9e5570ea4574dd
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:publish-by-null-datepublished
Merge into: launchpad:master
Diff against target: 374 lines (+112/-85)
8 files modified
database/sampledata/current-dev.sql (+1/-1)
database/sampledata/current.sql (+1/-1)
lib/lp/archivepublisher/publishing.py (+24/-17)
lib/lp/archivepublisher/scripts/publish_ftpmaster.py (+4/-7)
lib/lp/registry/model/distribution.py (+52/-52)
lib/lp/soyuz/interfaces/archive.py (+11/-1)
lib/lp/soyuz/model/archive.py (+15/-4)
lib/lp/soyuz/model/publishing.py (+4/-2)
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+384442@code.launchpad.net

Commit message

Publish based on NULL datepublished, not PENDING

Description of the change

PackagePublishingStatus conflates the intended state of the publication (published, superseded, deleted, obsolete) with the current on-disk state (pending, published, etc.). This makes it difficult to add variations needed to support Built-Using.

Instead of publishing rows whose status is PENDING, publish ones that have an active status and a NULL value for datepublished, indicating that they have never been published to disk but that they are intended to be.

The PENDING status remains for API compatibility and as a hint in the web UI, but it no longer controls publishing.

To post a comment you must log in.
3ab27f6... by Colin Watson

Publish based on NULL datepublished, not PENDING

PackagePublishingStatus conflates the intended state of the publication
(published, superseded, deleted, obsolete) with the current on-disk
state (pending, published, etc.). This makes it difficult to add
variations needed to support Built-Using.

Instead of publishing rows whose status is PENDING, publish ones that
have an active status and a NULL value for datepublished, indicating
that they have never been published to disk but that they are intended
to be.

The PENDING status remains for API compatibility and as a hint in the
web UI, but it no longer controls publishing.

Revision history for this message
William Grant (wgrant) :
review: Approve (code)
a96d92b... by Colin Watson

Only set PUBLISHED if current status is PENDING

In future we may have other active publishing statuses that should be
left as-is rather than set to PUBLISHED. Prepare for that now by being
slightly more careful in ArchivePublisherBase.setPublished.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/database/sampledata/current-dev.sql b/database/sampledata/current-dev.sql
index 191dd40..64cb226 100644
--- a/database/sampledata/current-dev.sql
+++ b/database/sampledata/current-dev.sql
@@ -4523,7 +4523,7 @@ INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseri
4523INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (27, 33, 10, 2, 1, 3, '2007-07-09 13:44:00.10654', '2007-07-09 14:14:00', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 24, NULL, NULL, NULL);4523INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (27, 33, 10, 2, 1, 3, '2007-07-09 13:44:00.10654', '2007-07-09 14:14:00', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 24, NULL, NULL, NULL);
4524INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (28, 35, 1, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 26, NULL, NULL, NULL);4524INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (28, 35, 1, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 26, NULL, NULL, NULL);
4525INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (29, 20, 1, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 14, NULL, NULL, NULL);4525INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (29, 20, 1, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 14, NULL, NULL, NULL);
4526INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (30, 36, 10, 2, 5, 7, '2007-08-09 21:28:12.106187', NULL, NULL, NULL, NULL, NULL, NULL, 0, 12, NULL, NULL, NULL, 27, NULL, NULL, NULL);4526INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (30, 36, 10, 2, 5, 7, '2007-08-09 21:28:12.106187', '2007-08-09 21:28:13', NULL, NULL, NULL, NULL, NULL, 0, 12, NULL, NULL, NULL, 27, NULL, NULL, NULL);
4527INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (31, 35, 10, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 10, NULL, NULL, NULL, 26, NULL, NULL, NULL);4527INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (31, 35, 10, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 10, NULL, NULL, NULL, 26, NULL, NULL, NULL);
4528INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (32, 38, 14, 1, 1, 3, '2006-02-15 12:19:00.05741', NULL, NULL, NULL, NULL, NULL, NULL, 0, 16, NULL, NULL, NULL, 19, NULL, NULL, NULL);4528INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (32, 38, 14, 1, 1, 3, '2006-02-15 12:19:00.05741', NULL, NULL, NULL, NULL, NULL, NULL, 0, 16, NULL, NULL, NULL, 19, NULL, NULL, NULL);
4529INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (33, 39, 1, 1, 1, 3, '2006-02-15 12:19:00.05741', NULL, NULL, NULL, NULL, NULL, NULL, 0, 1, NULL, NULL, NULL, 9, NULL, NULL, NULL);4529INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (33, 39, 1, 1, 1, 3, '2006-02-15 12:19:00.05741', NULL, NULL, NULL, NULL, NULL, NULL, 0, 1, NULL, NULL, NULL, 9, NULL, NULL, NULL);
diff --git a/database/sampledata/current.sql b/database/sampledata/current.sql
index be42368..5e9f4ea 100644
--- a/database/sampledata/current.sql
+++ b/database/sampledata/current.sql
@@ -4447,7 +4447,7 @@ INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseri
4447INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (27, 33, 10, 2, 1, 3, '2007-07-09 13:44:00.10654', '2007-07-09 14:14:00', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 24, NULL, NULL, NULL);4447INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (27, 33, 10, 2, 1, 3, '2007-07-09 13:44:00.10654', '2007-07-09 14:14:00', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 24, NULL, NULL, NULL);
4448INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (28, 35, 1, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 26, NULL, NULL, NULL);4448INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (28, 35, 1, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 26, NULL, NULL, NULL);
4449INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (29, 20, 1, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 14, NULL, NULL, NULL);4449INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (29, 20, 1, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 9, NULL, NULL, NULL, 14, NULL, NULL, NULL);
4450INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (30, 36, 10, 2, 5, 7, '2007-08-09 21:28:12.106187', NULL, NULL, NULL, NULL, NULL, NULL, 0, 12, NULL, NULL, NULL, 27, NULL, NULL, NULL);4450INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (30, 36, 10, 2, 5, 7, '2007-08-09 21:28:12.106187', '2007-08-09 21:28:13', NULL, NULL, NULL, NULL, NULL, 0, 12, NULL, NULL, NULL, 27, NULL, NULL, NULL);
4451INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (31, 35, 10, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 10, NULL, NULL, NULL, 26, NULL, NULL, NULL);4451INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseries, status, component, section, datecreated, datepublished, datesuperseded, supersededby, datemadepending, scheduleddeletiondate, dateremoved, pocket, archive, removed_by, removal_comment, ancestor, sourcepackagename, creator, sponsor, packageupload) VALUES (31, 35, 10, 2, 1, 3, '2007-07-09 12:00:00', '2007-07-09 12:00:01', NULL, NULL, NULL, NULL, NULL, 0, 10, NULL, NULL, NULL, 26, NULL, NULL, NULL);
44524452
44534453
diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py
index f6246b0..18f273a 100644
--- a/lib/lp/archivepublisher/publishing.py
+++ b/lib/lp/archivepublisher/publishing.py
@@ -537,16 +537,21 @@ class Publisher(object):
537537
538 def getPendingSourcePublications(self, is_careful):538 def getPendingSourcePublications(self, is_careful):
539 """Return the specific group of source records to be published."""539 """Return the specific group of source records to be published."""
540 # Careful publishing should include all PUBLISHED rows, normal run540 # Careful publishing should include all rows in active statuses
541 # only includes PENDING ones.541 # regardless of whether they have previously been published; a
542 statuses = [PackagePublishingStatus.PENDING]542 # normal run only includes rows in active statuses that have never
543 if is_careful:543 # been published.
544 statuses.append(PackagePublishingStatus.PUBLISHED)544 clauses = [
545 SourcePackagePublishingHistory.archive == self.archive,
546 SourcePackagePublishingHistory.status.is_in(
547 active_publishing_status),
548 ]
549 if not is_careful:
550 clauses.append(
551 SourcePackagePublishingHistory.datepublished == None)
545552
546 publications = IStore(SourcePackagePublishingHistory).find(553 publications = IStore(SourcePackagePublishingHistory).find(
547 SourcePackagePublishingHistory,554 SourcePackagePublishingHistory, *clauses)
548 SourcePackagePublishingHistory.archive == self.archive,
549 SourcePackagePublishingHistory.status.is_in(statuses))
550 return publications.order_by(555 return publications.order_by(
551 SourcePackagePublishingHistory.distroseriesID,556 SourcePackagePublishingHistory.distroseriesID,
552 SourcePackagePublishingHistory.pocket,557 SourcePackagePublishingHistory.pocket,
@@ -588,19 +593,21 @@ class Publisher(object):
588593
589 def getPendingBinaryPublications(self, is_careful):594 def getPendingBinaryPublications(self, is_careful):
590 """Return the specific group of binary records to be published."""595 """Return the specific group of binary records to be published."""
591 statuses = [PackagePublishingStatus.PENDING]596 clauses = [
592 if is_careful:
593 statuses.append(PackagePublishingStatus.PUBLISHED)
594
595 publications = IStore(BinaryPackagePublishingHistory).find(
596 BinaryPackagePublishingHistory,
597 BinaryPackagePublishingHistory.archive == self.archive,597 BinaryPackagePublishingHistory.archive == self.archive,
598 BinaryPackagePublishingHistory.distroarchseriesID ==598 BinaryPackagePublishingHistory.distroarchseriesID ==
599 DistroArchSeries.id,599 DistroArchSeries.id,
600 DistroArchSeries.distroseriesID == DistroSeries.id,600 BinaryPackagePublishingHistory.status.is_in(
601 BinaryPackagePublishingHistory.status.is_in(statuses))601 active_publishing_status),
602 ]
603 if not is_careful:
604 clauses.append(
605 BinaryPackagePublishingHistory.datepublished == None)
606
607 publications = IStore(BinaryPackagePublishingHistory).find(
608 BinaryPackagePublishingHistory, *clauses)
602 return publications.order_by(609 return publications.order_by(
603 DistroSeries.id,610 DistroArchSeries.distroseriesID,
604 BinaryPackagePublishingHistory.pocket,611 BinaryPackagePublishingHistory.pocket,
605 DistroArchSeries.architecturetag,612 DistroArchSeries.architecturetag,
606 Desc(BinaryPackagePublishingHistory.id))613 Desc(BinaryPackagePublishingHistory.id))
diff --git a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
index c307846..2610531 100644
--- a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
+++ b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
@@ -43,10 +43,7 @@ from lp.services.scripts.base import (
43 LaunchpadScriptFailure,43 LaunchpadScriptFailure,
44 )44 )
45from lp.services.utils import file_exists45from lp.services.utils import file_exists
46from lp.soyuz.enums import (46from lp.soyuz.enums import ArchivePurpose
47 ArchivePurpose,
48 PackagePublishingStatus,
49 )
50from lp.soyuz.model.distroarchseries import DistroArchSeries47from lp.soyuz.model.distroarchseries import DistroArchSeries
51from lp.soyuz.scripts.custom_uploads_copier import CustomUploadsCopier48from lp.soyuz.scripts.custom_uploads_copier import CustomUploadsCopier
5249
@@ -265,10 +262,10 @@ class PublishFTPMaster(LaunchpadCronScript):
265 self.logger.debug("Querying which suites are pending publication...")262 self.logger.debug("Querying which suites are pending publication...")
266263
267 archive = distribution.main_archive264 archive = distribution.main_archive
268 pending = PackagePublishingStatus.PENDING265 pending_sources = list(archive.getPublishedSources(
269 pending_sources = list(archive.getPublishedSources(status=pending))266 only_unpublished=True))
270 pending_binaries = list(archive.getAllPublishedBinaries(267 pending_binaries = list(archive.getAllPublishedBinaries(
271 status=pending))268 only_unpublished=True))
272 load_related(269 load_related(
273 DistroArchSeries, pending_binaries, ['distroarchseriesID'])270 DistroArchSeries, pending_binaries, ['distroarchseriesID'])
274 return set(271 return set(
diff --git a/lib/lp/registry/model/distribution.py b/lib/lp/registry/model/distribution.py
index 9c4c96e..33c1571 100644
--- a/lib/lp/registry/model/distribution.py
+++ b/lib/lp/registry/model/distribution.py
@@ -176,6 +176,7 @@ from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
176from lp.soyuz.interfaces.buildrecords import IHasBuildRecords176from lp.soyuz.interfaces.buildrecords import IHasBuildRecords
177from lp.soyuz.interfaces.publishing import active_publishing_status177from lp.soyuz.interfaces.publishing import active_publishing_status
178from lp.soyuz.model.archive import Archive178from lp.soyuz.model.archive import Archive
179from lp.soyuz.model.archivefile import ArchiveFile
179from lp.soyuz.model.binarypackagename import BinaryPackageName180from lp.soyuz.model.binarypackagename import BinaryPackageName
180from lp.soyuz.model.distributionsourcepackagerelease import (181from lp.soyuz.model.distributionsourcepackagerelease import (
181 DistributionSourcePackageRelease,182 DistributionSourcePackageRelease,
@@ -1288,60 +1289,59 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements,
12881289
1289 def getPendingPublicationPPAs(self):1290 def getPendingPublicationPPAs(self):
1290 """See `IDistribution`."""1291 """See `IDistribution`."""
1291 src_query = """1292 src_archives = IStore(Archive).find(
1292 Archive.purpose = %s AND1293 Archive,
1293 Archive.distribution = %s AND1294 Archive.purpose == ArchivePurpose.PPA,
1294 SourcePackagePublishingHistory.archive = archive.id AND1295 Archive.distribution == self,
1295 SourcePackagePublishingHistory.scheduleddeletiondate IS NULL AND1296 SourcePackagePublishingHistory.archive == Archive.id,
1296 SourcePackagePublishingHistory.dateremoved IS NULL AND1297 SourcePackagePublishingHistory.scheduleddeletiondate == None,
1297 SourcePackagePublishingHistory.status IN (%s, %s)1298 SourcePackagePublishingHistory.dateremoved == None,
1298 """ % sqlvalues(ArchivePurpose.PPA, self,1299 Or(
1299 PackagePublishingStatus.PENDING,1300 And(
1300 PackagePublishingStatus.DELETED)1301 SourcePackagePublishingHistory.status.is_in(
13011302 active_publishing_status),
1302 src_archives = Archive.select(1303 SourcePackagePublishingHistory.datepublished == None),
1303 src_query, clauseTables=['SourcePackagePublishingHistory'],1304 SourcePackagePublishingHistory.status ==
1304 orderBy=['archive.id'], distinct=True)1305 PackagePublishingStatus.DELETED,
13051306 )).order_by(Archive.id).config(distinct=True)
1306 bin_query = """1307
1307 Archive.purpose = %s AND1308 bin_archives = IStore(Archive).find(
1308 Archive.distribution = %s AND1309 Archive,
1309 BinaryPackagePublishingHistory.archive = archive.id AND1310 Archive.purpose == ArchivePurpose.PPA,
1310 BinaryPackagePublishingHistory.scheduleddeletiondate IS NULL AND1311 Archive.distribution == self,
1311 BinaryPackagePublishingHistory.dateremoved IS NULL AND1312 BinaryPackagePublishingHistory.archive == Archive.id,
1312 BinaryPackagePublishingHistory.status IN (%s, %s)1313 BinaryPackagePublishingHistory.scheduleddeletiondate == None,
1313 """ % sqlvalues(ArchivePurpose.PPA, self,1314 BinaryPackagePublishingHistory.dateremoved == None,
1314 PackagePublishingStatus.PENDING,1315 Or(
1315 PackagePublishingStatus.DELETED)1316 And(
13161317 BinaryPackagePublishingHistory.status.is_in(
1317 bin_archives = Archive.select(1318 active_publishing_status),
1318 bin_query, clauseTables=['BinaryPackagePublishingHistory'],1319 BinaryPackagePublishingHistory.datepublished == None),
1319 orderBy=['archive.id'], distinct=True)1320 BinaryPackagePublishingHistory.status ==
13201321 PackagePublishingStatus.DELETED,
1321 reapable_af_query = """1322 )).order_by(Archive.id).config(distinct=True)
1322 Archive.purpose = %s AND1323
1323 Archive.distribution = %s AND1324 reapable_af_archives = IStore(Archive).find(
1324 ArchiveFile.archive = archive.id AND1325 Archive,
1325 ArchiveFile.scheduled_deletion_date < %s1326 Archive.purpose == ArchivePurpose.PPA,
1326 """ % sqlvalues(ArchivePurpose.PPA, self, UTC_NOW)1327 Archive.distribution == self,
13271328 ArchiveFile.archive == Archive.id,
1328 reapable_af_archives = Archive.select(1329 ArchiveFile.scheduled_deletion_date < UTC_NOW,
1329 reapable_af_query, clauseTables=['ArchiveFile'],1330 ).order_by(Archive.id).config(distinct=True)
1330 orderBy=['archive.id'], distinct=True)
1331
1332 dirty_suites_query = """
1333 Archive.purpose = %s AND
1334 Archive.distribution = %s AND
1335 Archive.dirty_suites IS NOT NULL
1336 """ % sqlvalues(ArchivePurpose.PPA, self)
13371331
1338 dirty_suites_archives = Archive.select(1332 dirty_suites_archives = IStore(Archive).find(
1339 dirty_suites_query, orderBy=['archive.id'])1333 Archive,
1334 Archive.purpose == ArchivePurpose.PPA,
1335 Archive.distribution == self,
1336 Archive.dirty_suites != None,
1337 ).order_by(Archive.id)
13401338
1341 deleting_archives = Archive.selectBy(1339 deleting_archives = IStore(Archive).find(
1342 distribution=self,1340 Archive,
1343 purpose=ArchivePurpose.PPA,1341 Archive.purpose == ArchivePurpose.PPA,
1344 status=ArchiveStatus.DELETING).orderBy(['archive.id'])1342 Archive.distribution == self,
1343 Archive.status == ArchiveStatus.DELETING,
1344 ).order_by(Archive.id)
13451345
1346 return src_archives.union(bin_archives).union(1346 return src_archives.union(bin_archives).union(
1347 reapable_af_archives).union(dirty_suites_archives).union(1347 reapable_af_archives).union(dirty_suites_archives).union(
diff --git a/lib/lp/soyuz/interfaces/archive.py b/lib/lp/soyuz/interfaces/archive.py
index 8d34ec4..0e82e27 100644
--- a/lib/lp/soyuz/interfaces/archive.py
+++ b/lib/lp/soyuz/interfaces/archive.py
@@ -543,7 +543,8 @@ class IArchiveSubscriberView(Interface):
543 distroseries=None, pocket=None,543 distroseries=None, pocket=None,
544 exact_match=False, created_since_date=None,544 exact_match=False, created_since_date=None,
545 eager_load=False, component_name=None,545 eager_load=False, component_name=None,
546 order_by_date=False):546 order_by_date=False, include_removed=True,
547 only_unpublished=False):
547 """All `ISourcePackagePublishingHistory` target to this archive.548 """All `ISourcePackagePublishingHistory` target to this archive.
548549
549 :param name: source name filter (exact match or SQL LIKE controlled550 :param name: source name filter (exact match or SQL LIKE controlled
@@ -566,6 +567,10 @@ class IArchiveSubscriberView(Interface):
566 If not specified, publications are ordered by source567 If not specified, publications are ordered by source
567 package name (lexicographically), then by descending version568 package name (lexicographically), then by descending version
568 and then descending ID.569 and then descending ID.
570 :param include_removed: If True, include publications that have been
571 removed from disk as well as those that have not.
572 :param only_unpublished: If True, only include publications that
573 have never been published to disk.
569574
570 :return: SelectResults containing `ISourcePackagePublishingHistory`,575 :return: SelectResults containing `ISourcePackagePublishingHistory`,
571 ordered by name. If there are multiple results for the same576 ordered by name. If there are multiple results for the same
@@ -1239,6 +1244,7 @@ class IArchiveView(IHasBuildRecords):
1239 distroarchseries=None, pocket=None,1244 distroarchseries=None, pocket=None,
1240 exact_match=False, created_since_date=None,1245 exact_match=False, created_since_date=None,
1241 ordered=True, order_by_date=False,1246 ordered=True, order_by_date=False,
1247 include_removed=True, only_unpublished=False,
1242 eager_load=False):1248 eager_load=False):
1243 """All `IBinaryPackagePublishingHistory` target to this archive.1249 """All `IBinaryPackagePublishingHistory` target to this archive.
12441250
@@ -1260,6 +1266,10 @@ class IArchiveView(IHasBuildRecords):
1260 :param order_by_date: Order publications by descending creation date1266 :param order_by_date: Order publications by descending creation date
1261 and then by descending ID. This is suitable for applications1267 and then by descending ID. This is suitable for applications
1262 that need to catch up with publications since their last run.1268 that need to catch up with publications since their last run.
1269 :param include_removed: If True, include publications that have been
1270 removed from disk as well as those that have not.
1271 :param only_unpublished: If True, only include publications that
1272 have never been published to disk.
12631273
1264 :return: A collection containing `BinaryPackagePublishingHistory`.1274 :return: A collection containing `BinaryPackagePublishingHistory`.
1265 """1275 """
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index c496824..acf8541 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -617,7 +617,8 @@ class Archive(SQLBase):
617 distroseries=None, pocket=None,617 distroseries=None, pocket=None,
618 exact_match=False, created_since_date=None,618 exact_match=False, created_since_date=None,
619 eager_load=False, component_name=None,619 eager_load=False, component_name=None,
620 order_by_date=False, include_removed=True):620 order_by_date=False, include_removed=True,
621 only_unpublished=False):
621 """See `IArchive`."""622 """See `IArchive`."""
622 clauses = [SourcePackagePublishingHistory.archiveID == self.id]623 clauses = [SourcePackagePublishingHistory.archiveID == self.id]
623624
@@ -693,6 +694,10 @@ class Archive(SQLBase):
693 if not include_removed:694 if not include_removed:
694 clauses.append(SourcePackagePublishingHistory.dateremoved == None)695 clauses.append(SourcePackagePublishingHistory.dateremoved == None)
695696
697 if only_unpublished:
698 clauses.append(
699 SourcePackagePublishingHistory.datepublished == None)
700
696 store = Store.of(self)701 store = Store.of(self)
697 resultset = store.find(702 resultset = store.find(
698 SourcePackagePublishingHistory, *clauses).order_by(*order_by)703 SourcePackagePublishingHistory, *clauses).order_by(*order_by)
@@ -803,7 +808,7 @@ class Archive(SQLBase):
803 self, name=None, version=None, status=None, distroarchseries=None,808 self, name=None, version=None, status=None, distroarchseries=None,
804 pocket=None, exact_match=False, created_since_date=None,809 pocket=None, exact_match=False, created_since_date=None,
805 ordered=True, order_by_date=False, include_removed=True,810 ordered=True, order_by_date=False, include_removed=True,
806 need_bpr=False):811 only_unpublished=False, need_bpr=False):
807 """Base clauses for binary publishing queries.812 """Base clauses for binary publishing queries.
808813
809 Returns a list of 'clauses' (to be joined in the callsite).814 Returns a list of 'clauses' (to be joined in the callsite).
@@ -880,13 +885,18 @@ class Archive(SQLBase):
880 if not include_removed:885 if not include_removed:
881 clauses.append(BinaryPackagePublishingHistory.dateremoved == None)886 clauses.append(BinaryPackagePublishingHistory.dateremoved == None)
882887
888 if only_unpublished:
889 clauses.append(
890 BinaryPackagePublishingHistory.datepublished == None)
891
883 return clauses, order_by892 return clauses, order_by
884893
885 def getAllPublishedBinaries(self, name=None, version=None, status=None,894 def getAllPublishedBinaries(self, name=None, version=None, status=None,
886 distroarchseries=None, pocket=None,895 distroarchseries=None, pocket=None,
887 exact_match=False, created_since_date=None,896 exact_match=False, created_since_date=None,
888 ordered=True, order_by_date=False,897 ordered=True, order_by_date=False,
889 include_removed=True, eager_load=False):898 include_removed=True, only_unpublished=False,
899 eager_load=False):
890 """See `IArchive`."""900 """See `IArchive`."""
891 # Circular imports.901 # Circular imports.
892 from lp.registry.model.distroseries import DistroSeries902 from lp.registry.model.distroseries import DistroSeries
@@ -896,7 +906,8 @@ class Archive(SQLBase):
896 name=name, version=version, status=status, pocket=pocket,906 name=name, version=version, status=status, pocket=pocket,
897 distroarchseries=distroarchseries, exact_match=exact_match,907 distroarchseries=distroarchseries, exact_match=exact_match,
898 created_since_date=created_since_date, ordered=ordered,908 created_since_date=created_since_date, ordered=ordered,
899 order_by_date=order_by_date, include_removed=include_removed)909 order_by_date=order_by_date, include_removed=include_removed,
910 only_unpublished=only_unpublished)
900911
901 result = Store.of(self).find(912 result = Store.of(self).find(
902 BinaryPackagePublishingHistory, *clauses).order_by(*order_by)913 BinaryPackagePublishingHistory, *clauses).order_by(*order_by)
diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
index 1c5d384..5e6173a 100644
--- a/lib/lp/soyuz/model/publishing.py
+++ b/lib/lp/soyuz/model/publishing.py
@@ -157,12 +157,14 @@ class ArchivePublisherBase:
157 """see IArchiveSafePublisher."""157 """see IArchiveSafePublisher."""
158 # XXX cprov 2006-06-14:158 # XXX cprov 2006-06-14:
159 # Implement sanity checks before set it as published159 # Implement sanity checks before set it as published
160 if self.status == PackagePublishingStatus.PENDING:160 if (self.status in active_publishing_status and
161 self.datepublished is None):
161 # update the DB publishing record status if they162 # update the DB publishing record status if they
162 # are pending, don't do anything for the ones163 # are pending, don't do anything for the ones
163 # already published (usually when we use -C164 # already published (usually when we use -C
164 # publish-distro.py option)165 # publish-distro.py option)
165 self.status = PackagePublishingStatus.PUBLISHED166 if self.status == PackagePublishingStatus.PENDING:
167 self.status = PackagePublishingStatus.PUBLISHED
166 self.datepublished = UTC_NOW168 self.datepublished = UTC_NOW
167169
168 def publish(self, diskpool, log):170 def publish(self, diskpool, log):

Subscribers

People subscribed via source and target branches

to status/vote changes: