~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Jeroen Vermeulen
  • Date: 2011-09-08 05:25:29 UTC
  • mto: This revision was merged to the branch mainline in revision 13911.
  • Revision ID: jeroen.vermeulen@canonical.com-20110908052529-qx6mharbtjcbqymi
Review changes: docstrings & comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
193
193
    def dominatePackage(self, publications, live_versions, generalization):
194
194
        """Dominate publications for a single package.
195
195
 
 
196
        Active publications for versions in `live_versions` stay active.
 
197
        Any older versions are marked as superseded by the respective
 
198
        oldest live versions that are newer than the superseded ones.
 
199
 
 
200
        Any versions that are newer than anything in `live_versions` are
 
201
        marked as deleted.  This should not be possible in Soyuz-native
 
202
        archives, but it can happen during archive imports when the
 
203
        previous latest version of a package has disappeared from the Sources
 
204
        list we import.
 
205
 
196
206
        :param publications: Iterable of publications for the same package,
197
207
            in the same archive, series, and pocket, all with status
198
208
            `PackagePublishingStatus.PUBLISHED`.
199
209
        :param live_versions: Iterable of version strings that are still
200
210
            considered live for this package.  The given publications will
201
211
            remain active insofar as they represent any of these versions;
202
 
            the other publications will be marked superseded.
 
212
            older publications will be marked as superseded and newer ones
 
213
            as deleted.
203
214
        :param generalization: A `GeneralizedPublication` helper representing
204
215
            the kind of publications these are--source or binary.
205
216
        """
230
241
    def _dominatePublications(self, pubs, generalization):
231
242
        """Perform dominations for the given publications.
232
243
 
 
244
        Keep the latest published version for each package active,
 
245
        superseding older versions.
 
246
 
233
247
        :param pubs: A dict mapping names to a list of publications. Every
234
248
            publication must be PUBLISHED or PENDING, and the first in each
235
249
            list will be treated as dominant (so should be the latest).
237
251
            the kind of publications these are--source or binary.
238
252
        """
239
253
        self.logger.debug("Dominating packages...")
240
 
 
241
254
        for name, publications in pubs.iteritems():
242
255
            assert publications, "Empty list of publications for %s." % name
 
256
            # Since this always picks the latest version as the live
 
257
            # one, this dominatePackage call will never result in a
 
258
            # deletion.
243
259
            latest_version = generalization.getPackageVersion(publications[0])
244
260
            self.dominatePackage(
245
261
                publications, [latest_version], generalization)