Merge ~cjwatson/launchpad:publish-by-null-datepublished into launchpad:master
- Git
- lp:~cjwatson/launchpad
- publish-by-null-datepublished
- Merge into master
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) |
||||
Related bugs: |
|
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
PackagePublishi
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.
- 3ab27f6... by Colin Watson
-
Publish based on NULL datepublished, not PENDING
PackagePublishi
ngStatus 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.
William Grant (wgrant) : | # |
- 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.setPublis hed.
Preview Diff
1 | diff --git a/database/sampledata/current-dev.sql b/database/sampledata/current-dev.sql | |||
2 | index 191dd40..64cb226 100644 | |||
3 | --- a/database/sampledata/current-dev.sql | |||
4 | +++ b/database/sampledata/current-dev.sql | |||
5 | @@ -4523,7 +4523,7 @@ INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseri | |||
6 | 4523 | INSERT 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); | 4523 | INSERT 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); |
7 | 4524 | INSERT 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); | 4524 | INSERT 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); |
8 | 4525 | INSERT 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); | 4525 | INSERT 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); |
10 | 4526 | INSERT 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); | 4526 | INSERT 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); |
11 | 4527 | INSERT 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); | 4527 | INSERT 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); |
12 | 4528 | INSERT 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); | 4528 | INSERT 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); |
13 | 4529 | INSERT 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); | 4529 | INSERT 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); |
14 | diff --git a/database/sampledata/current.sql b/database/sampledata/current.sql | |||
15 | index be42368..5e9f4ea 100644 | |||
16 | --- a/database/sampledata/current.sql | |||
17 | +++ b/database/sampledata/current.sql | |||
18 | @@ -4447,7 +4447,7 @@ INSERT INTO sourcepackagepublishinghistory (id, sourcepackagerelease, distroseri | |||
19 | 4447 | INSERT 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); | 4447 | INSERT 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); |
20 | 4448 | INSERT 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); | 4448 | INSERT 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); |
21 | 4449 | INSERT 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); | 4449 | INSERT 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); |
23 | 4450 | INSERT 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); | 4450 | INSERT 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); |
24 | 4451 | INSERT 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); | 4451 | INSERT 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); |
25 | 4452 | 4452 | ||
26 | 4453 | 4453 | ||
27 | diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py | |||
28 | index f6246b0..18f273a 100644 | |||
29 | --- a/lib/lp/archivepublisher/publishing.py | |||
30 | +++ b/lib/lp/archivepublisher/publishing.py | |||
31 | @@ -537,16 +537,21 @@ class Publisher(object): | |||
32 | 537 | 537 | ||
33 | 538 | def getPendingSourcePublications(self, is_careful): | 538 | def getPendingSourcePublications(self, is_careful): |
34 | 539 | """Return the specific group of source records to be published.""" | 539 | """Return the specific group of source records to be published.""" |
40 | 540 | # Careful publishing should include all PUBLISHED rows, normal run | 540 | # Careful publishing should include all rows in active statuses |
41 | 541 | # only includes PENDING ones. | 541 | # regardless of whether they have previously been published; a |
42 | 542 | statuses = [PackagePublishingStatus.PENDING] | 542 | # normal run only includes rows in active statuses that have never |
43 | 543 | if is_careful: | 543 | # been published. |
44 | 544 | statuses.append(PackagePublishingStatus.PUBLISHED) | 544 | clauses = [ |
45 | 545 | SourcePackagePublishingHistory.archive == self.archive, | ||
46 | 546 | SourcePackagePublishingHistory.status.is_in( | ||
47 | 547 | active_publishing_status), | ||
48 | 548 | ] | ||
49 | 549 | if not is_careful: | ||
50 | 550 | clauses.append( | ||
51 | 551 | SourcePackagePublishingHistory.datepublished == None) | ||
52 | 545 | 552 | ||
53 | 546 | publications = IStore(SourcePackagePublishingHistory).find( | 553 | publications = IStore(SourcePackagePublishingHistory).find( |
57 | 547 | SourcePackagePublishingHistory, | 554 | SourcePackagePublishingHistory, *clauses) |
55 | 548 | SourcePackagePublishingHistory.archive == self.archive, | ||
56 | 549 | SourcePackagePublishingHistory.status.is_in(statuses)) | ||
58 | 550 | return publications.order_by( | 555 | return publications.order_by( |
59 | 551 | SourcePackagePublishingHistory.distroseriesID, | 556 | SourcePackagePublishingHistory.distroseriesID, |
60 | 552 | SourcePackagePublishingHistory.pocket, | 557 | SourcePackagePublishingHistory.pocket, |
61 | @@ -588,19 +593,21 @@ class Publisher(object): | |||
62 | 588 | 593 | ||
63 | 589 | def getPendingBinaryPublications(self, is_careful): | 594 | def getPendingBinaryPublications(self, is_careful): |
64 | 590 | """Return the specific group of binary records to be published.""" | 595 | """Return the specific group of binary records to be published.""" |
71 | 591 | statuses = [PackagePublishingStatus.PENDING] | 596 | clauses = [ |
66 | 592 | if is_careful: | ||
67 | 593 | statuses.append(PackagePublishingStatus.PUBLISHED) | ||
68 | 594 | |||
69 | 595 | publications = IStore(BinaryPackagePublishingHistory).find( | ||
70 | 596 | BinaryPackagePublishingHistory, | ||
72 | 597 | BinaryPackagePublishingHistory.archive == self.archive, | 597 | BinaryPackagePublishingHistory.archive == self.archive, |
73 | 598 | BinaryPackagePublishingHistory.distroarchseriesID == | 598 | BinaryPackagePublishingHistory.distroarchseriesID == |
74 | 599 | DistroArchSeries.id, | 599 | DistroArchSeries.id, |
77 | 600 | DistroArchSeries.distroseriesID == DistroSeries.id, | 600 | BinaryPackagePublishingHistory.status.is_in( |
78 | 601 | BinaryPackagePublishingHistory.status.is_in(statuses)) | 601 | active_publishing_status), |
79 | 602 | ] | ||
80 | 603 | if not is_careful: | ||
81 | 604 | clauses.append( | ||
82 | 605 | BinaryPackagePublishingHistory.datepublished == None) | ||
83 | 606 | |||
84 | 607 | publications = IStore(BinaryPackagePublishingHistory).find( | ||
85 | 608 | BinaryPackagePublishingHistory, *clauses) | ||
86 | 602 | return publications.order_by( | 609 | return publications.order_by( |
88 | 603 | DistroSeries.id, | 610 | DistroArchSeries.distroseriesID, |
89 | 604 | BinaryPackagePublishingHistory.pocket, | 611 | BinaryPackagePublishingHistory.pocket, |
90 | 605 | DistroArchSeries.architecturetag, | 612 | DistroArchSeries.architecturetag, |
91 | 606 | Desc(BinaryPackagePublishingHistory.id)) | 613 | Desc(BinaryPackagePublishingHistory.id)) |
92 | diff --git a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py | |||
93 | index c307846..2610531 100644 | |||
94 | --- a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py | |||
95 | +++ b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py | |||
96 | @@ -43,10 +43,7 @@ from lp.services.scripts.base import ( | |||
97 | 43 | LaunchpadScriptFailure, | 43 | LaunchpadScriptFailure, |
98 | 44 | ) | 44 | ) |
99 | 45 | from lp.services.utils import file_exists | 45 | from lp.services.utils import file_exists |
104 | 46 | from lp.soyuz.enums import ( | 46 | from lp.soyuz.enums import ArchivePurpose |
101 | 47 | ArchivePurpose, | ||
102 | 48 | PackagePublishingStatus, | ||
103 | 49 | ) | ||
105 | 50 | from lp.soyuz.model.distroarchseries import DistroArchSeries | 47 | from lp.soyuz.model.distroarchseries import DistroArchSeries |
106 | 51 | from lp.soyuz.scripts.custom_uploads_copier import CustomUploadsCopier | 48 | from lp.soyuz.scripts.custom_uploads_copier import CustomUploadsCopier |
107 | 52 | 49 | ||
108 | @@ -265,10 +262,10 @@ class PublishFTPMaster(LaunchpadCronScript): | |||
109 | 265 | self.logger.debug("Querying which suites are pending publication...") | 262 | self.logger.debug("Querying which suites are pending publication...") |
110 | 266 | 263 | ||
111 | 267 | archive = distribution.main_archive | 264 | archive = distribution.main_archive |
114 | 268 | pending = PackagePublishingStatus.PENDING | 265 | pending_sources = list(archive.getPublishedSources( |
115 | 269 | pending_sources = list(archive.getPublishedSources(status=pending)) | 266 | only_unpublished=True)) |
116 | 270 | pending_binaries = list(archive.getAllPublishedBinaries( | 267 | pending_binaries = list(archive.getAllPublishedBinaries( |
118 | 271 | status=pending)) | 268 | only_unpublished=True)) |
119 | 272 | load_related( | 269 | load_related( |
120 | 273 | DistroArchSeries, pending_binaries, ['distroarchseriesID']) | 270 | DistroArchSeries, pending_binaries, ['distroarchseriesID']) |
121 | 274 | return set( | 271 | return set( |
122 | diff --git a/lib/lp/registry/model/distribution.py b/lib/lp/registry/model/distribution.py | |||
123 | index 9c4c96e..33c1571 100644 | |||
124 | --- a/lib/lp/registry/model/distribution.py | |||
125 | +++ b/lib/lp/registry/model/distribution.py | |||
126 | @@ -176,6 +176,7 @@ from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet | |||
127 | 176 | from lp.soyuz.interfaces.buildrecords import IHasBuildRecords | 176 | from lp.soyuz.interfaces.buildrecords import IHasBuildRecords |
128 | 177 | from lp.soyuz.interfaces.publishing import active_publishing_status | 177 | from lp.soyuz.interfaces.publishing import active_publishing_status |
129 | 178 | from lp.soyuz.model.archive import Archive | 178 | from lp.soyuz.model.archive import Archive |
130 | 179 | from lp.soyuz.model.archivefile import ArchiveFile | ||
131 | 179 | from lp.soyuz.model.binarypackagename import BinaryPackageName | 180 | from lp.soyuz.model.binarypackagename import BinaryPackageName |
132 | 180 | from lp.soyuz.model.distributionsourcepackagerelease import ( | 181 | from lp.soyuz.model.distributionsourcepackagerelease import ( |
133 | 181 | DistributionSourcePackageRelease, | 182 | DistributionSourcePackageRelease, |
134 | @@ -1288,60 +1289,59 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements, | |||
135 | 1288 | 1289 | ||
136 | 1289 | def getPendingPublicationPPAs(self): | 1290 | def getPendingPublicationPPAs(self): |
137 | 1290 | """See `IDistribution`.""" | 1291 | """See `IDistribution`.""" |
184 | 1291 | src_query = """ | 1292 | src_archives = IStore(Archive).find( |
185 | 1292 | Archive.purpose = %s AND | 1293 | Archive, |
186 | 1293 | Archive.distribution = %s AND | 1294 | Archive.purpose == ArchivePurpose.PPA, |
187 | 1294 | SourcePackagePublishingHistory.archive = archive.id AND | 1295 | Archive.distribution == self, |
188 | 1295 | SourcePackagePublishingHistory.scheduleddeletiondate IS NULL AND | 1296 | SourcePackagePublishingHistory.archive == Archive.id, |
189 | 1296 | SourcePackagePublishingHistory.dateremoved IS NULL AND | 1297 | SourcePackagePublishingHistory.scheduleddeletiondate == None, |
190 | 1297 | SourcePackagePublishingHistory.status IN (%s, %s) | 1298 | SourcePackagePublishingHistory.dateremoved == None, |
191 | 1298 | """ % sqlvalues(ArchivePurpose.PPA, self, | 1299 | Or( |
192 | 1299 | PackagePublishingStatus.PENDING, | 1300 | And( |
193 | 1300 | PackagePublishingStatus.DELETED) | 1301 | SourcePackagePublishingHistory.status.is_in( |
194 | 1301 | 1302 | active_publishing_status), | |
195 | 1302 | src_archives = Archive.select( | 1303 | SourcePackagePublishingHistory.datepublished == None), |
196 | 1303 | src_query, clauseTables=['SourcePackagePublishingHistory'], | 1304 | SourcePackagePublishingHistory.status == |
197 | 1304 | orderBy=['archive.id'], distinct=True) | 1305 | PackagePublishingStatus.DELETED, |
198 | 1305 | 1306 | )).order_by(Archive.id).config(distinct=True) | |
199 | 1306 | bin_query = """ | 1307 | |
200 | 1307 | Archive.purpose = %s AND | 1308 | bin_archives = IStore(Archive).find( |
201 | 1308 | Archive.distribution = %s AND | 1309 | Archive, |
202 | 1309 | BinaryPackagePublishingHistory.archive = archive.id AND | 1310 | Archive.purpose == ArchivePurpose.PPA, |
203 | 1310 | BinaryPackagePublishingHistory.scheduleddeletiondate IS NULL AND | 1311 | Archive.distribution == self, |
204 | 1311 | BinaryPackagePublishingHistory.dateremoved IS NULL AND | 1312 | BinaryPackagePublishingHistory.archive == Archive.id, |
205 | 1312 | BinaryPackagePublishingHistory.status IN (%s, %s) | 1313 | BinaryPackagePublishingHistory.scheduleddeletiondate == None, |
206 | 1313 | """ % sqlvalues(ArchivePurpose.PPA, self, | 1314 | BinaryPackagePublishingHistory.dateremoved == None, |
207 | 1314 | PackagePublishingStatus.PENDING, | 1315 | Or( |
208 | 1315 | PackagePublishingStatus.DELETED) | 1316 | And( |
209 | 1316 | 1317 | BinaryPackagePublishingHistory.status.is_in( | |
210 | 1317 | bin_archives = Archive.select( | 1318 | active_publishing_status), |
211 | 1318 | bin_query, clauseTables=['BinaryPackagePublishingHistory'], | 1319 | BinaryPackagePublishingHistory.datepublished == None), |
212 | 1319 | orderBy=['archive.id'], distinct=True) | 1320 | BinaryPackagePublishingHistory.status == |
213 | 1320 | 1321 | PackagePublishingStatus.DELETED, | |
214 | 1321 | reapable_af_query = """ | 1322 | )).order_by(Archive.id).config(distinct=True) |
215 | 1322 | Archive.purpose = %s AND | 1323 | |
216 | 1323 | Archive.distribution = %s AND | 1324 | reapable_af_archives = IStore(Archive).find( |
217 | 1324 | ArchiveFile.archive = archive.id AND | 1325 | Archive, |
218 | 1325 | ArchiveFile.scheduled_deletion_date < %s | 1326 | Archive.purpose == ArchivePurpose.PPA, |
219 | 1326 | """ % sqlvalues(ArchivePurpose.PPA, self, UTC_NOW) | 1327 | Archive.distribution == self, |
220 | 1327 | 1328 | ArchiveFile.archive == Archive.id, | |
221 | 1328 | reapable_af_archives = Archive.select( | 1329 | ArchiveFile.scheduled_deletion_date < UTC_NOW, |
222 | 1329 | reapable_af_query, clauseTables=['ArchiveFile'], | 1330 | ).order_by(Archive.id).config(distinct=True) |
177 | 1330 | orderBy=['archive.id'], distinct=True) | ||
178 | 1331 | |||
179 | 1332 | dirty_suites_query = """ | ||
180 | 1333 | Archive.purpose = %s AND | ||
181 | 1334 | Archive.distribution = %s AND | ||
182 | 1335 | Archive.dirty_suites IS NOT NULL | ||
183 | 1336 | """ % sqlvalues(ArchivePurpose.PPA, self) | ||
223 | 1337 | 1331 | ||
226 | 1338 | dirty_suites_archives = Archive.select( | 1332 | dirty_suites_archives = IStore(Archive).find( |
227 | 1339 | dirty_suites_query, orderBy=['archive.id']) | 1333 | Archive, |
228 | 1334 | Archive.purpose == ArchivePurpose.PPA, | ||
229 | 1335 | Archive.distribution == self, | ||
230 | 1336 | Archive.dirty_suites != None, | ||
231 | 1337 | ).order_by(Archive.id) | ||
232 | 1340 | 1338 | ||
237 | 1341 | deleting_archives = Archive.selectBy( | 1339 | deleting_archives = IStore(Archive).find( |
238 | 1342 | distribution=self, | 1340 | Archive, |
239 | 1343 | purpose=ArchivePurpose.PPA, | 1341 | Archive.purpose == ArchivePurpose.PPA, |
240 | 1344 | status=ArchiveStatus.DELETING).orderBy(['archive.id']) | 1342 | Archive.distribution == self, |
241 | 1343 | Archive.status == ArchiveStatus.DELETING, | ||
242 | 1344 | ).order_by(Archive.id) | ||
243 | 1345 | 1345 | ||
244 | 1346 | return src_archives.union(bin_archives).union( | 1346 | return src_archives.union(bin_archives).union( |
245 | 1347 | reapable_af_archives).union(dirty_suites_archives).union( | 1347 | reapable_af_archives).union(dirty_suites_archives).union( |
246 | diff --git a/lib/lp/soyuz/interfaces/archive.py b/lib/lp/soyuz/interfaces/archive.py | |||
247 | index 8d34ec4..0e82e27 100644 | |||
248 | --- a/lib/lp/soyuz/interfaces/archive.py | |||
249 | +++ b/lib/lp/soyuz/interfaces/archive.py | |||
250 | @@ -543,7 +543,8 @@ class IArchiveSubscriberView(Interface): | |||
251 | 543 | distroseries=None, pocket=None, | 543 | distroseries=None, pocket=None, |
252 | 544 | exact_match=False, created_since_date=None, | 544 | exact_match=False, created_since_date=None, |
253 | 545 | eager_load=False, component_name=None, | 545 | eager_load=False, component_name=None, |
255 | 546 | order_by_date=False): | 546 | order_by_date=False, include_removed=True, |
256 | 547 | only_unpublished=False): | ||
257 | 547 | """All `ISourcePackagePublishingHistory` target to this archive. | 548 | """All `ISourcePackagePublishingHistory` target to this archive. |
258 | 548 | 549 | ||
259 | 549 | :param name: source name filter (exact match or SQL LIKE controlled | 550 | :param name: source name filter (exact match or SQL LIKE controlled |
260 | @@ -566,6 +567,10 @@ class IArchiveSubscriberView(Interface): | |||
261 | 566 | If not specified, publications are ordered by source | 567 | If not specified, publications are ordered by source |
262 | 567 | package name (lexicographically), then by descending version | 568 | package name (lexicographically), then by descending version |
263 | 568 | and then descending ID. | 569 | and then descending ID. |
264 | 570 | :param include_removed: If True, include publications that have been | ||
265 | 571 | removed from disk as well as those that have not. | ||
266 | 572 | :param only_unpublished: If True, only include publications that | ||
267 | 573 | have never been published to disk. | ||
268 | 569 | 574 | ||
269 | 570 | :return: SelectResults containing `ISourcePackagePublishingHistory`, | 575 | :return: SelectResults containing `ISourcePackagePublishingHistory`, |
270 | 571 | ordered by name. If there are multiple results for the same | 576 | ordered by name. If there are multiple results for the same |
271 | @@ -1239,6 +1244,7 @@ class IArchiveView(IHasBuildRecords): | |||
272 | 1239 | distroarchseries=None, pocket=None, | 1244 | distroarchseries=None, pocket=None, |
273 | 1240 | exact_match=False, created_since_date=None, | 1245 | exact_match=False, created_since_date=None, |
274 | 1241 | ordered=True, order_by_date=False, | 1246 | ordered=True, order_by_date=False, |
275 | 1247 | include_removed=True, only_unpublished=False, | ||
276 | 1242 | eager_load=False): | 1248 | eager_load=False): |
277 | 1243 | """All `IBinaryPackagePublishingHistory` target to this archive. | 1249 | """All `IBinaryPackagePublishingHistory` target to this archive. |
278 | 1244 | 1250 | ||
279 | @@ -1260,6 +1266,10 @@ class IArchiveView(IHasBuildRecords): | |||
280 | 1260 | :param order_by_date: Order publications by descending creation date | 1266 | :param order_by_date: Order publications by descending creation date |
281 | 1261 | and then by descending ID. This is suitable for applications | 1267 | and then by descending ID. This is suitable for applications |
282 | 1262 | that need to catch up with publications since their last run. | 1268 | that need to catch up with publications since their last run. |
283 | 1269 | :param include_removed: If True, include publications that have been | ||
284 | 1270 | removed from disk as well as those that have not. | ||
285 | 1271 | :param only_unpublished: If True, only include publications that | ||
286 | 1272 | have never been published to disk. | ||
287 | 1263 | 1273 | ||
288 | 1264 | :return: A collection containing `BinaryPackagePublishingHistory`. | 1274 | :return: A collection containing `BinaryPackagePublishingHistory`. |
289 | 1265 | """ | 1275 | """ |
290 | diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py | |||
291 | index c496824..acf8541 100644 | |||
292 | --- a/lib/lp/soyuz/model/archive.py | |||
293 | +++ b/lib/lp/soyuz/model/archive.py | |||
294 | @@ -617,7 +617,8 @@ class Archive(SQLBase): | |||
295 | 617 | distroseries=None, pocket=None, | 617 | distroseries=None, pocket=None, |
296 | 618 | exact_match=False, created_since_date=None, | 618 | exact_match=False, created_since_date=None, |
297 | 619 | eager_load=False, component_name=None, | 619 | eager_load=False, component_name=None, |
299 | 620 | order_by_date=False, include_removed=True): | 620 | order_by_date=False, include_removed=True, |
300 | 621 | only_unpublished=False): | ||
301 | 621 | """See `IArchive`.""" | 622 | """See `IArchive`.""" |
302 | 622 | clauses = [SourcePackagePublishingHistory.archiveID == self.id] | 623 | clauses = [SourcePackagePublishingHistory.archiveID == self.id] |
303 | 623 | 624 | ||
304 | @@ -693,6 +694,10 @@ class Archive(SQLBase): | |||
305 | 693 | if not include_removed: | 694 | if not include_removed: |
306 | 694 | clauses.append(SourcePackagePublishingHistory.dateremoved == None) | 695 | clauses.append(SourcePackagePublishingHistory.dateremoved == None) |
307 | 695 | 696 | ||
308 | 697 | if only_unpublished: | ||
309 | 698 | clauses.append( | ||
310 | 699 | SourcePackagePublishingHistory.datepublished == None) | ||
311 | 700 | |||
312 | 696 | store = Store.of(self) | 701 | store = Store.of(self) |
313 | 697 | resultset = store.find( | 702 | resultset = store.find( |
314 | 698 | SourcePackagePublishingHistory, *clauses).order_by(*order_by) | 703 | SourcePackagePublishingHistory, *clauses).order_by(*order_by) |
315 | @@ -803,7 +808,7 @@ class Archive(SQLBase): | |||
316 | 803 | self, name=None, version=None, status=None, distroarchseries=None, | 808 | self, name=None, version=None, status=None, distroarchseries=None, |
317 | 804 | pocket=None, exact_match=False, created_since_date=None, | 809 | pocket=None, exact_match=False, created_since_date=None, |
318 | 805 | ordered=True, order_by_date=False, include_removed=True, | 810 | ordered=True, order_by_date=False, include_removed=True, |
320 | 806 | need_bpr=False): | 811 | only_unpublished=False, need_bpr=False): |
321 | 807 | """Base clauses for binary publishing queries. | 812 | """Base clauses for binary publishing queries. |
322 | 808 | 813 | ||
323 | 809 | Returns a list of 'clauses' (to be joined in the callsite). | 814 | Returns a list of 'clauses' (to be joined in the callsite). |
324 | @@ -880,13 +885,18 @@ class Archive(SQLBase): | |||
325 | 880 | if not include_removed: | 885 | if not include_removed: |
326 | 881 | clauses.append(BinaryPackagePublishingHistory.dateremoved == None) | 886 | clauses.append(BinaryPackagePublishingHistory.dateremoved == None) |
327 | 882 | 887 | ||
328 | 888 | if only_unpublished: | ||
329 | 889 | clauses.append( | ||
330 | 890 | BinaryPackagePublishingHistory.datepublished == None) | ||
331 | 891 | |||
332 | 883 | return clauses, order_by | 892 | return clauses, order_by |
333 | 884 | 893 | ||
334 | 885 | def getAllPublishedBinaries(self, name=None, version=None, status=None, | 894 | def getAllPublishedBinaries(self, name=None, version=None, status=None, |
335 | 886 | distroarchseries=None, pocket=None, | 895 | distroarchseries=None, pocket=None, |
336 | 887 | exact_match=False, created_since_date=None, | 896 | exact_match=False, created_since_date=None, |
337 | 888 | ordered=True, order_by_date=False, | 897 | ordered=True, order_by_date=False, |
339 | 889 | include_removed=True, eager_load=False): | 898 | include_removed=True, only_unpublished=False, |
340 | 899 | eager_load=False): | ||
341 | 890 | """See `IArchive`.""" | 900 | """See `IArchive`.""" |
342 | 891 | # Circular imports. | 901 | # Circular imports. |
343 | 892 | from lp.registry.model.distroseries import DistroSeries | 902 | from lp.registry.model.distroseries import DistroSeries |
344 | @@ -896,7 +906,8 @@ class Archive(SQLBase): | |||
345 | 896 | name=name, version=version, status=status, pocket=pocket, | 906 | name=name, version=version, status=status, pocket=pocket, |
346 | 897 | distroarchseries=distroarchseries, exact_match=exact_match, | 907 | distroarchseries=distroarchseries, exact_match=exact_match, |
347 | 898 | created_since_date=created_since_date, ordered=ordered, | 908 | created_since_date=created_since_date, ordered=ordered, |
349 | 899 | order_by_date=order_by_date, include_removed=include_removed) | 909 | order_by_date=order_by_date, include_removed=include_removed, |
350 | 910 | only_unpublished=only_unpublished) | ||
351 | 900 | 911 | ||
352 | 901 | result = Store.of(self).find( | 912 | result = Store.of(self).find( |
353 | 902 | BinaryPackagePublishingHistory, *clauses).order_by(*order_by) | 913 | BinaryPackagePublishingHistory, *clauses).order_by(*order_by) |
354 | diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py | |||
355 | index 1c5d384..5e6173a 100644 | |||
356 | --- a/lib/lp/soyuz/model/publishing.py | |||
357 | +++ b/lib/lp/soyuz/model/publishing.py | |||
358 | @@ -157,12 +157,14 @@ class ArchivePublisherBase: | |||
359 | 157 | """see IArchiveSafePublisher.""" | 157 | """see IArchiveSafePublisher.""" |
360 | 158 | # XXX cprov 2006-06-14: | 158 | # XXX cprov 2006-06-14: |
361 | 159 | # Implement sanity checks before set it as published | 159 | # Implement sanity checks before set it as published |
363 | 160 | if self.status == PackagePublishingStatus.PENDING: | 160 | if (self.status in active_publishing_status and |
364 | 161 | self.datepublished is None): | ||
365 | 161 | # update the DB publishing record status if they | 162 | # update the DB publishing record status if they |
366 | 162 | # are pending, don't do anything for the ones | 163 | # are pending, don't do anything for the ones |
367 | 163 | # already published (usually when we use -C | 164 | # already published (usually when we use -C |
368 | 164 | # publish-distro.py option) | 165 | # publish-distro.py option) |
370 | 165 | self.status = PackagePublishingStatus.PUBLISHED | 166 | if self.status == PackagePublishingStatus.PENDING: |
371 | 167 | self.status = PackagePublishingStatus.PUBLISHED | ||
372 | 166 | self.datepublished = UTC_NOW | 168 | self.datepublished = UTC_NOW |
373 | 167 | 169 | ||
374 | 168 | def publish(self, diskpool, log): | 170 | def publish(self, diskpool, log): |