~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archivepublisher/domination.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-09-26 15:32:36 UTC
  • mfrom: (14017.3.5 post-857155)
  • Revision ID: launchpad@pqm.canonical.com-20110926153236-pdldzk96qfb71z51
[r=allenap][bug=857155] Bit more optimization and a renaming for Gina
 domination.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    )
70
70
from canonical.launchpad.interfaces.lpstorm import IStore
71
71
from lp.registry.model.sourcepackagename import SourcePackageName
 
72
from lp.services.database.bulk import load_related
72
73
from lp.soyuz.enums import (
73
74
    BinaryPackageFormat,
74
75
    PackagePublishingStatus,
109
110
    Used by `GeneralizedPublication` to hide the differences from
110
111
    `BinaryPackagePublishingHistory`.
111
112
    """
 
113
    release_class = SourcePackageRelease
 
114
    release_reference_name = 'sourcepackagereleaseID'
 
115
 
112
116
    @staticmethod
113
117
    def getPackageName(spph):
114
118
        """Return the name of this publication's source package."""
126
130
    Used by `GeneralizedPublication` to hide the differences from
127
131
    `SourcePackagePublishingHistory`.
128
132
    """
 
133
    release_class = BinaryPackageRelease
 
134
    release_reference_name = 'binarypackagereleaseID'
 
135
 
129
136
    @staticmethod
130
137
    def getPackageName(bpph):
131
138
        """Return the name of this publication's binary package."""
156
163
        return self.traits.getPackageName(pub)
157
164
 
158
165
    def getPackageVersion(self, pub):
159
 
        """Obtain the version string for a publicaiton record."""
 
166
        """Obtain the version string for a publication record."""
160
167
        return self.traits.getPackageRelease(pub).version
161
168
 
 
169
    def load_releases(self, pubs):
 
170
        """Load the releases associated with a series of publications."""
 
171
        return load_related(
 
172
            self.traits.release_class, pubs,
 
173
            [self.traits.release_reference_name])
 
174
 
162
175
    def compare(self, pub1, pub2):
163
176
        """Compare publications by version.
164
177
 
217
230
        :param generalization: A `GeneralizedPublication` helper representing
218
231
            the kind of publications these are--source or binary.
219
232
        """
 
233
        publications = list(publications)
 
234
        generalization.load_releases(publications)
 
235
 
220
236
        # Go through publications from latest version to oldest.  This
221
237
        # makes it easy to figure out which release superseded which:
222
238
        # the dominant is always the oldest live release that is newer
558
574
            Desc(SourcePackageRelease.version),
559
575
            Desc(SourcePackagePublishingHistory.datecreated))
560
576
 
561
 
    def dominateRemovedSourceVersions(self, distroseries, pocket,
562
 
                                      package_name, live_versions):
 
577
    def dominateSourceVersions(self, distroseries, pocket, package_name,
 
578
                               live_versions):
563
579
        """Dominate source publications based on a set of "live" versions.
564
580
 
565
581
        Active publications for the "live" versions will remain active.  All