launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24704
[Merge] ~cjwatson/launchpad:use-more-publishing-status-helpers into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:use-more-publishing-status-helpers into launchpad:master.
Commit message:
Use the (in)active_publishing_status helpers in more places
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/383710
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:use-more-publishing-status-helpers into launchpad:master.
diff --git a/lib/lp/scripts/garbo.py b/lib/lp/scripts/garbo.py
index e5a9e07..98c4b04 100644
--- a/lib/lp/scripts/garbo.py
+++ b/lib/lp/scripts/garbo.py
@@ -118,7 +118,7 @@ from lp.services.webhooks.interfaces import IWebhookJobSource
from lp.services.webhooks.model import WebhookJob
from lp.snappy.model.snapbuild import SnapFile
from lp.snappy.model.snapbuildjob import SnapBuildJobType
-from lp.soyuz.enums import PackagePublishingStatus
+from lp.soyuz.interfaces.publishing import active_publishing_status
from lp.soyuz.model.archive import Archive
from lp.soyuz.model.distributionsourcepackagecache import (
DistributionSourcePackageCache,
@@ -470,9 +470,8 @@ class PopulateDistributionSourcePackageCache(TunableLoop):
Archive.distributionID,
SourcePackageName.id,
SourcePackageName.name),
- SourcePackagePublishingHistory.status.is_in((
- PackagePublishingStatus.PENDING,
- PackagePublishingStatus.PUBLISHED)),
+ SourcePackagePublishingHistory.status.is_in(
+ active_publishing_status),
SourcePackagePublishingHistory.id > self.last_spph_id)
return rows.order_by(SourcePackagePublishingHistory.id)
diff --git a/lib/lp/soyuz/adapters/overrides.py b/lib/lp/soyuz/adapters/overrides.py
index 8d585f1..a8d609d 100644
--- a/lib/lp/soyuz/adapters/overrides.py
+++ b/lib/lp/soyuz/adapters/overrides.py
@@ -37,6 +37,7 @@ from lp.services.database.decoratedresultset import DecoratedResultSet
from lp.services.database.interfaces import IStore
from lp.soyuz.enums import PackagePublishingStatus
from lp.soyuz.interfaces.component import IComponentSet
+from lp.soyuz.interfaces.publishing import active_publishing_status
from lp.soyuz.model.binarypackagename import BinaryPackageName
from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
from lp.soyuz.model.component import Component
@@ -230,10 +231,7 @@ class FromExistingOverridePolicy(BaseOverridePolicy):
super(FromExistingOverridePolicy, self).__init__(*args, **kwargs)
def getExistingPublishingStatuses(self, include_deleted):
- status = [
- PackagePublishingStatus.PENDING,
- PackagePublishingStatus.PUBLISHED,
- ]
+ status = list(active_publishing_status)
if include_deleted:
status.append(PackagePublishingStatus.DELETED)
return status
diff --git a/lib/lp/soyuz/doc/archive.txt b/lib/lp/soyuz/doc/archive.txt
index 484b643..e9c2424 100644
--- a/lib/lp/soyuz/doc/archive.txt
+++ b/lib/lp/soyuz/doc/archive.txt
@@ -250,12 +250,10 @@ excludes architecture-independent duplications which is necessary for
having correct publication counters and archive size.
>>> from lp.soyuz.enums import PackagePublishingStatus
-
- >>> active_status = [PackagePublishingStatus.PENDING,
- ... PackagePublishingStatus.PUBLISHED]
-
- >>> inactive_status = [PackagePublishingStatus.SUPERSEDED,
- ... PackagePublishingStatus.DELETED]
+ >>> from lp.soyuz.interfaces.publishing import (
+ ... active_publishing_status,
+ ... inactive_publishing_status,
+ ... )
>>> warty = cprov_archive.distribution['warty']
>>> hoary = cprov_archive.distribution['hoary']
@@ -365,19 +363,19 @@ Both methods support 'status' filter:
4
>>> cprov_archive.getPublishedOnDiskBinaries(
- ... status=active_status).count()
+ ... status=active_publishing_status).count()
3
>>> cprov_archive.getAllPublishedBinaries(
- ... status=active_status).count()
+ ... status=active_publishing_status).count()
4
>>> cprov_archive.getPublishedOnDiskBinaries(
- ... status=inactive_status).count()
+ ... status=inactive_publishing_status).count()
0
>>> cprov_archive.getAllPublishedBinaries(
- ... status=inactive_status).count()
+ ... status=inactive_publishing_status).count()
0
Using 'distroarchseries' filter:
@@ -429,44 +427,44 @@ Using 'pocket' filter:
Associating 'name' and 'status' filters:
>>> status_lookup = cprov_archive.getPublishedOnDiskBinaries(
- ... name=u'pmount', status=active_status)
+ ... name=u'pmount', status=active_publishing_status)
>>> status_lookup.count()
1
>>> status_lookup = cprov_archive.getAllPublishedBinaries(
- ... name=u'pmount', status=active_status)
+ ... name=u'pmount', status=active_publishing_status)
>>> status_lookup.count()
2
>>> status_lookup = cprov_archive.getPublishedOnDiskBinaries(
- ... name=u'foo', status=active_status)
+ ... name=u'foo', status=active_publishing_status)
>>> status_lookup.count()
0
>>> status_lookup = cprov_archive.getAllPublishedBinaries(
- ... name=u'foo', status=active_status)
+ ... name=u'foo', status=active_publishing_status)
>>> status_lookup.count()
0
Associating 'name', 'version' and 'status' filters:
>>> status_lookup = cprov_archive.getPublishedOnDiskBinaries(
- ... name=u'pmount', version='0.1-1', status=active_status)
+ ... name=u'pmount', version='0.1-1', status=active_publishing_status)
>>> status_lookup.count()
1
>>> status_lookup = cprov_archive.getAllPublishedBinaries(
- ... name=u'pmount', version='0.1-1', status=active_status)
+ ... name=u'pmount', version='0.1-1', status=active_publishing_status)
>>> status_lookup.count()
2
>>> status_lookup = cprov_archive.getPublishedOnDiskBinaries(
- ... name=u'pmount', version='666', status=active_status)
+ ... name=u'pmount', version='666', status=active_publishing_status)
>>> status_lookup.count()
0
>>> status_lookup = cprov_archive.getAllPublishedBinaries(
- ... name=u'pmount', version='666', status=active_status)
+ ... name=u'pmount', version='666', status=active_publishing_status)
>>> status_lookup.count()
0
@@ -475,14 +473,14 @@ and 'exact_match' flag:
>>> status_lookup = cprov_archive.getAllPublishedBinaries(
... name=u'pmount', version='0.1-1', distroarchseries=warty_i386,
- ... status=active_status, exact_match=True)
+ ... status=active_publishing_status, exact_match=True)
>>> status_lookup.count()
1
>>> status_lookup = cprov_archive.getAllPublishedBinaries(
... name=u'pmount', version='0.1-1',
... distroarchseries=[warty_i386, warty_hppa],
- ... status=active_status, exact_match=True)
+ ... status=active_publishing_status, exact_match=True)
>>> status_lookup.count()
2
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index 6e430ec..a693166 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -1915,8 +1915,7 @@ class Archive(SQLBase):
# publication.
published_sources = from_archive.getPublishedSources(
name=name, distroseries=from_series_obj, exact_match=True,
- status=(PackagePublishingStatus.PUBLISHED,
- PackagePublishingStatus.PENDING))
+ status=active_publishing_status)
first_source = published_sources.first()
if first_source is not None:
sources.append(first_source)
diff --git a/lib/lp/soyuz/model/distributionsourcepackagecache.py b/lib/lp/soyuz/model/distributionsourcepackagecache.py
index 1fe14a3..c68f71f 100644
--- a/lib/lp/soyuz/model/distributionsourcepackagecache.py
+++ b/lib/lp/soyuz/model/distributionsourcepackagecache.py
@@ -23,10 +23,10 @@ from lp.services.database import bulk
from lp.services.database.decoratedresultset import DecoratedResultSet
from lp.services.database.interfaces import IStore
from lp.services.database.sqlbase import SQLBase
-from lp.soyuz.enums import PackagePublishingStatus
from lp.soyuz.interfaces.distributionsourcepackagecache import (
IDistributionSourcePackageCache,
)
+from lp.soyuz.interfaces.publishing import active_publishing_status
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
from lp.soyuz.model.binarypackagename import BinaryPackageName
from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
@@ -76,9 +76,8 @@ class DistributionSourcePackageCache(SQLBase):
spn_ids = IStore(SourcePackagePublishingHistory).find(
SourcePackagePublishingHistory.sourcepackagenameID,
SourcePackagePublishingHistory.archive == archive,
- SourcePackagePublishingHistory.status.is_in((
- PackagePublishingStatus.PENDING,
- PackagePublishingStatus.PUBLISHED)))
+ SourcePackagePublishingHistory.status.is_in(
+ active_publishing_status))
return bulk.load(SourcePackageName, spn_ids.config(distinct=True))
@classmethod
@@ -151,9 +150,8 @@ class DistributionSourcePackageCache(SQLBase):
SourcePackagePublishingHistory.sourcepackagenameID.is_in(
[spn.id for spn in sourcepackagenames]),
SourcePackagePublishingHistory.archive == archive,
- SourcePackagePublishingHistory.status.is_in((
- PackagePublishingStatus.PENDING,
- PackagePublishingStatus.PUBLISHED))
+ SourcePackagePublishingHistory.status.is_in(
+ active_publishing_status),
).config(distinct=True).order_by(SourcePackageRelease.id))
if len(all_sprs) == 0:
if log is not None:
diff --git a/lib/lp/soyuz/model/distroseriespackagecache.py b/lib/lp/soyuz/model/distroseriespackagecache.py
index cabf07e..9bccd11 100644
--- a/lib/lp/soyuz/model/distroseriespackagecache.py
+++ b/lib/lp/soyuz/model/distroseriespackagecache.py
@@ -24,10 +24,10 @@ from zope.interface import implementer
from lp.services.database import bulk
from lp.services.database.interfaces import IStore
from lp.services.database.sqlbase import SQLBase
-from lp.soyuz.enums import PackagePublishingStatus
from lp.soyuz.interfaces.distroseriespackagecache import (
IDistroSeriesPackageCache,
)
+from lp.soyuz.interfaces.publishing import active_publishing_status
from lp.soyuz.model.binarypackagename import BinaryPackageName
from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
from lp.soyuz.model.distroarchseries import DistroArchSeries
@@ -61,10 +61,8 @@ class DistroSeriesPackageCache(SQLBase):
DistroArchSeries.id, tables=[DistroArchSeries],
where=DistroArchSeries.distroseries == distroseries)),
BinaryPackagePublishingHistory.archive == archive,
- BinaryPackagePublishingHistory.status.is_in((
- PackagePublishingStatus.PENDING,
- PackagePublishingStatus.PUBLISHED))).config(
- distinct=True)
+ BinaryPackagePublishingHistory.status.is_in(
+ active_publishing_status)).config(distinct=True)
return bulk.load(BinaryPackageName, bpn_ids)
@classmethod
@@ -134,9 +132,8 @@ class DistroSeriesPackageCache(SQLBase):
DistroArchSeries.id, tables=[DistroArchSeries],
where=DistroArchSeries.distroseries == distroseries)),
BinaryPackagePublishingHistory.archive == archive,
- BinaryPackagePublishingHistory.status.is_in((
- PackagePublishingStatus.PENDING,
- PackagePublishingStatus.PUBLISHED))
+ BinaryPackagePublishingHistory.status.is_in(
+ active_publishing_status),
).group_by(
BinaryPackageRelease.binarypackagenameID,
BinaryPackageRelease.summary,
diff --git a/lib/lp/soyuz/scripts/initialize_distroseries.py b/lib/lp/soyuz/scripts/initialize_distroseries.py
index 8ac2150..308ba42 100644
--- a/lib/lp/soyuz/scripts/initialize_distroseries.py
+++ b/lib/lp/soyuz/scripts/initialize_distroseries.py
@@ -29,7 +29,6 @@ from lp.services.scripts import log
from lp.soyuz.adapters.packagelocation import PackageLocation
from lp.soyuz.enums import (
ArchivePurpose,
- PackagePublishingStatus,
PackageUploadStatus,
)
from lp.soyuz.interfaces.archive import (
@@ -45,6 +44,7 @@ from lp.soyuz.interfaces.packageset import (
IPackagesetSet,
NoSuchPackageSet,
)
+from lp.soyuz.interfaces.publishing import active_publishing_status
from lp.soyuz.interfaces.queue import IPackageUploadSet
from lp.soyuz.model.binarypackagebuild import COPY_ARCHIVE_SCORE_PENALTY
from lp.soyuz.model.packageset import Packageset
@@ -577,9 +577,7 @@ class InitializeDistroSeries:
INIT_POCKETS.items()):
sources = archive.getPublishedSources(
distroseries=parent, pocket=source_pocket,
- status=(PackagePublishingStatus.PENDING,
- PackagePublishingStatus.PUBLISHED),
- name=spns)
+ status=active_publishing_status, name=spns)
sources_published.extend(do_copy(
sources, target_archive, self.distroseries,
target_pocket,
diff --git a/lib/lp/soyuz/tests/test_archive.py b/lib/lp/soyuz/tests/test_archive.py
index 8660e70..caef680 100644
--- a/lib/lp/soyuz/tests/test_archive.py
+++ b/lib/lp/soyuz/tests/test_archive.py
@@ -113,6 +113,10 @@ from lp.soyuz.interfaces.binarypackagebuild import BuildSetStatus
from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
from lp.soyuz.interfaces.component import IComponentSet
from lp.soyuz.interfaces.packagecopyjob import IPlainPackageCopyJobSource
+from lp.soyuz.interfaces.publishing import (
+ active_publishing_status,
+ inactive_publishing_status,
+ )
from lp.soyuz.model.archive import (
Archive,
validate_ppa,
@@ -2580,10 +2584,6 @@ class TestGetPublishedSources(TestCaseWithFactory):
# publications.
self.assertEqual(3, cprov_archive.getPublishedSources().count())
# Various filters.
- active_status = [PackagePublishingStatus.PENDING,
- PackagePublishingStatus.PUBLISHED]
- inactive_status = [PackagePublishingStatus.SUPERSEDED,
- PackagePublishingStatus.DELETED]
warty = cprov_archive.distribution['warty']
hoary = cprov_archive.distribution['hoary']
breezy_autotest = cprov_archive.distribution['breezy-autotest']
@@ -2616,9 +2616,9 @@ class TestGetPublishedSources(TestCaseWithFactory):
self.assertEqual(3, cprov_archive.getPublishedSources(
status=PackagePublishingStatus.PUBLISHED).count())
self.assertEqual(3, cprov_archive.getPublishedSources(
- status=active_status).count())
+ status=active_publishing_status).count())
self.assertEqual(0, cprov_archive.getPublishedSources(
- status=inactive_status).count())
+ status=inactive_publishing_status).count())
self.assertEqual(2, cprov_archive.getPublishedSources(
distroseries=warty).count())
self.assertEqual(0, cprov_archive.getPublishedSources(