~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/model/publishing.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-24 11:48:32 UTC
  • mfrom: (13045.15.17 copies-use-overrides)
  • Revision ID: launchpad@pqm.canonical.com-20110524114832-oya6nkj2qd820p4w
[r=julian-edwards,
        wgrant][bug=783249] Add support for generic overrides to the package
        copier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
800
800
            section=new_section,
801
801
            archive=current.archive)
802
802
 
803
 
    def copyTo(self, distroseries, pocket, archive):
 
803
    def copyTo(self, distroseries, pocket, archive, policy=None):
804
804
        """See `ISourcePackagePublishingHistory`."""
 
805
        component = self.component
 
806
        section = self.section
 
807
        if policy is not None:
 
808
            packages = (self.sourcepackagerelease.sourcepackagename,)
 
809
            override = policy.calculateSourceOverrides(
 
810
                archive, distroseries, pocket, packages)
 
811
            [spn, new_component, new_section] = override[0]
 
812
            if new_component is not None:
 
813
                component = new_component
 
814
            if new_section is not None:
 
815
                section = new_section
805
816
        return getUtility(IPublishingSet).newSourcePublication(
806
817
            archive,
807
818
            self.sourcepackagerelease,
808
819
            distroseries,
809
 
            self.component,
810
 
            self.section,
 
820
            component,
 
821
            section,
811
822
            pocket)
812
823
 
813
824
    def getStatusSummaryForBuilds(self):
1326
1337
 
1327
1338
    implements(IPublishingSet)
1328
1339
 
1329
 
    def copyBinariesTo(self, binaries, distroseries, pocket, archive):
 
1340
    def copyBinariesTo(self, binaries, distroseries, pocket, archive,
 
1341
                       policy=None):
1330
1342
        """See `IPublishingSet`."""
1331
 
        return self.publishBinaries(
1332
 
            archive, distroseries, pocket,
1333
 
            dict(
 
1343
        if policy is not None:
 
1344
            bpn_archtag = {}
 
1345
            for bpph in binaries:
 
1346
                bpn_archtag[(
 
1347
                    bpph.binarypackagerelease.binarypackagename,
 
1348
                    bpph.distroarchseries.architecturetag)] = bpph
 
1349
            with_overrides = {}
 
1350
            overrides = policy.calculateBinaryOverrides(
 
1351
                archive, distroseries, pocket, bpn_archtag.keys())
 
1352
            for bpn, das, component, section, priority in overrides:
 
1353
                bpph = bpn_archtag[(bpn, das.architecturetag)]
 
1354
                new_component = component or bpph.component
 
1355
                new_section = section or bpph.section
 
1356
                new_priority = priority or bpph.priority
 
1357
                calculated = (new_component, new_section, new_priority)
 
1358
                with_overrides[bpph.binarypackagerelease] = calculated
 
1359
        else:
 
1360
            with_overrides = dict(
1334
1361
                (bpph.binarypackagerelease, (bpph.component, bpph.section,
1335
 
                 bpph.priority)) for bpph in binaries))
 
1362
                 bpph.priority)) for bpph in binaries)
 
1363
        return self.publishBinaries(
 
1364
            archive, distroseries, pocket, with_overrides)
1336
1365
 
1337
1366
    def publishBinaries(self, archive, distroseries, pocket,
1338
1367
                        binaries):