launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #17176
[Merge] lp:~wgrant/launchpad/overrides-dicts into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/overrides-dicts into lp:launchpad with lp:~wgrant/launchpad/overrides-take-overrides as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/overrides-dicts/+merge/227305
--
https://code.launchpad.net/~wgrant/launchpad/overrides-dicts/+merge/227305
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/overrides-dicts into lp:launchpad.
=== modified file 'lib/lp/soyuz/adapters/overrides.py'
--- lib/lp/soyuz/adapters/overrides.py 2014-07-17 11:04:01 +0000
+++ lib/lp/soyuz/adapters/overrides.py 2014-07-21 05:57:28 +0000
@@ -58,8 +58,7 @@
class ISourceOverride(IOverride):
"""Source-specific overrides on a publication."""
- source_package_name = Attribute(
- "The ISourcePackageName that's being overridden")
+ pass
class IBinaryOverride(IOverride):
@@ -78,7 +77,7 @@
class Override:
"""See `IOverride`."""
- def __init__(self, component, section):
+ def __init__(self, component=None, section=None):
self.component = component
self.section = section
@@ -96,39 +95,29 @@
"""See `ISourceOverride`."""
implements(ISourceOverride)
- def __init__(self, source_package_name, component=None, section=None):
- super(SourceOverride, self).__init__(component, section)
- self.source_package_name = source_package_name
-
def __eq__(self, other):
return (
- self.source_package_name == other.source_package_name and
self.component == other.component and
self.section == other.section)
def __repr__(self):
return (
- "<%s at %x source_package_name=%r component=%r section=%r>" %
- (self.__class__.__name__, id(self), self.source_package_name,
- self.component, self.section))
+ "<%s at %x component=%r section=%r>" %
+ (self.__class__.__name__, id(self), self.component, self.section))
class BinaryOverride(Override):
"""See `IBinaryOverride`."""
implements(IBinaryOverride)
- def __init__(self, binary_package_name, architecture_tag, component=None,
- section=None, priority=None, phased_update_percentage=None):
+ def __init__(self, component=None, section=None, priority=None,
+ phased_update_percentage=None):
super(BinaryOverride, self).__init__(component, section)
- self.binary_package_name = binary_package_name
- self.architecture_tag = architecture_tag
self.priority = priority
self.phased_update_percentage = phased_update_percentage
def __eq__(self, other):
return (
- self.binary_package_name == other.binary_package_name and
- self.architecture_tag == other.architecture_tag and
self.component == other.component and
self.section == other.section and
self.priority == other.priority and
@@ -136,11 +125,9 @@
def __repr__(self):
return (
- "<%s at %x binary_package_name=%r architecture_tag=%r "
- "component=%r section=%r priority=%r "
+ "<%s at %x component=%r section=%r priority=%r "
"phased_update_percentage=%r>" %
- (self.__class__.__name__, id(self), self.binary_package_name,
- self.architecture_tag, self.component, self.section,
+ (self.__class__.__name__, id(self), self.component, self.section,
self.priority, self.phased_update_percentage))
@@ -163,9 +150,10 @@
:param archive: The target `IArchive`.
:param distroseries: The target `IDistroSeries`.
:param pocket: The target `PackagePublishingPocket`.
- :param sources: A tuple of `ISourceOverride`s.
+ :param sources: A dict mapping `ISourcePackageName`s to
+ `ISourceOverride`s.
- :return: A list of `ISourceOverride`
+ :return: A dict mapping `ISourcePackageName`s to `ISourceOverride`s.
"""
pass
@@ -175,11 +163,12 @@
:param archive: The target `IArchive`.
:param distroseries: The target `IDistroSeries`.
:param pocket: The target `PackagePublishingPocket`.
- :param binaries: A tuple of `IBinaryPackageName`, architecturetag
- pairs. Architecturetag can be None for architecture-independent
- publications.
+ :param binaries: A dict mapping (`IBinaryPackageName`, architecturetag)
+ pairs to `IBinaryOverride`s. Architecturetag can be None for
+ architecture-independent publications.
- :return: A list of `IBinaryOverride`
+ :return: A dict mapping (`IBinaryPackageName`, architecturetag)
+ pairs to `IBinaryOverride`s.
"""
pass
@@ -224,7 +213,7 @@
bulk.load(Component, (row[1] for row in rows))
bulk.load(Section, (row[2] for row in rows))
- spns = [override.source_package_name for override in sources]
+ spns = sources.keys()
store = IStore(SourcePackagePublishingHistory)
already_published = DecoratedResultSet(
store.find(
@@ -246,9 +235,9 @@
SourcePackagePublishingHistory.sourcepackagenameID,)),
id_resolver((SourcePackageName, Component, Section)),
pre_iter_hook=eager_load)
- return [
- SourceOverride(name, component=component, section=section)
- for (name, component, section) in already_published]
+ return dict(
+ (name, SourceOverride(component=component, section=section))
+ for (name, component, section) in already_published)
def calculateBinaryOverrides(self, archive, distroseries, pocket,
binaries, include_deleted=False):
@@ -257,16 +246,13 @@
bulk.load(Section, (row[3] for row in rows))
store = IStore(BinaryPackagePublishingHistory)
- expanded = calculate_target_das(
- distroseries,
- [(override.binary_package_name, override.architecture_tag)
- for override in binaries])
+ expanded = calculate_target_das(distroseries, binaries.keys())
candidates = [
make_package_condition(archive, das, bpn)
for bpn, das in expanded if das is not None]
if len(candidates) == 0:
- return []
+ return {}
# Do not copy phased_update_percentage from existing publications;
# it is too context-dependent to copy.
already_published = DecoratedResultSet(
@@ -294,12 +280,11 @@
pre_iter_hook=eager_load)
# XXX: This should return None for arch-indep, not the
# nominatedarchindep archtag.
- return [
- BinaryOverride(
- name, das.architecturetag, component=component,
- section=section, priority=priority,
- phased_update_percentage=self.phased_update_percentage)
- for name, das, component, section, priority in already_published]
+ return dict(
+ ((name, das.architecturetag), BinaryOverride(
+ component=component, section=section, priority=priority,
+ phased_update_percentage=self.phased_update_percentage))
+ for name, das, component, section, priority in already_published)
class UnknownOverridePolicy(BaseOverridePolicy):
@@ -339,25 +324,23 @@
return override_component_name
def calculateSourceOverrides(self, archive, distroseries, pocket, sources):
- return [
- SourceOverride(
- override.source_package_name,
+ return dict(
+ (spn, SourceOverride(
component=(
archive.default_component or
UnknownOverridePolicy.getComponentOverride(
- override.component, return_component=True)))
- for override in sources]
+ override.component, return_component=True))))
+ for spn, override in sources.items())
def calculateBinaryOverrides(self, archive, distroseries, pocket,
binaries):
default_component = archive.default_component or getUtility(
IComponentSet)['universe']
- return [
- BinaryOverride(
- override.binary_package_name, override.architecture_tag,
+ return dict(
+ ((binary_package_name, architecture_tag), BinaryOverride(
component=default_component,
- phased_update_percentage=self.phased_update_percentage)
- for override in binaries]
+ phased_update_percentage=self.phased_update_percentage))
+ for binary_package_name, architecture_tag in binaries.keys())
class UbuntuOverridePolicy(FromExistingOverridePolicy,
@@ -369,39 +352,31 @@
"""
def calculateSourceOverrides(self, archive, distroseries, pocket, sources):
- spns = [override.source_package_name for override in sources]
- total = set(spns)
+ total = set(sources.keys())
overrides = FromExistingOverridePolicy.calculateSourceOverrides(
self, archive, distroseries, pocket, sources, include_deleted=True)
- existing = set(override.source_package_name for override in overrides)
+ existing = set(overrides.keys())
missing = total.difference(existing)
if missing:
unknown = UnknownOverridePolicy.calculateSourceOverrides(
self, archive, distroseries, pocket,
- [override for override in sources
- if override.source_package_name in missing])
- overrides.extend(unknown)
+ dict((spn, sources[spn]) for spn in missing))
+ overrides.update(unknown)
return overrides
def calculateBinaryOverrides(self, archive, distroseries, pocket,
binaries):
- total = set(
- (override.binary_package_name, override.architecture_tag)
- for override in binaries)
+ total = set(binaries.keys())
overrides = FromExistingOverridePolicy.calculateBinaryOverrides(
self, archive, distroseries, pocket, binaries,
include_deleted=True)
- existing = set(
- (override.binary_package_name, override.architecture_tag)
- for override in overrides)
+ existing = set(overrides.keys())
missing = total.difference(existing)
if missing:
unknown = UnknownOverridePolicy.calculateBinaryOverrides(
self, archive, distroseries, pocket,
- [override for override in binaries
- if (override.binary_package_name, override.architecture_tag)
- in missing])
- overrides.extend(unknown)
+ dict((key, binaries[key]) for key in missing))
+ overrides.update(unknown)
return overrides
=== modified file 'lib/lp/soyuz/adapters/tests/test_overrides.py'
--- lib/lp/soyuz/adapters/tests/test_overrides.py 2014-07-17 13:34:45 +0000
+++ lib/lp/soyuz/adapters/tests/test_overrides.py 2014-07-21 05:57:28 +0000
@@ -41,8 +41,8 @@
policy = FromExistingOverridePolicy()
overrides = policy.calculateSourceOverrides(
distroseries.main_archive, distroseries, pocket,
- [SourceOverride(spn)])
- self.assertEqual([], overrides)
+ {spn: SourceOverride()})
+ self.assertEqual({}, overrides)
def test_source_overrides(self):
# When the spn is published in the given archive/distroseries, the
@@ -51,10 +51,10 @@
policy = FromExistingOverridePolicy()
overrides = policy.calculateSourceOverrides(
spph.distroseries.main_archive, spph.distroseries, spph.pocket,
- [SourceOverride(spph.sourcepackagerelease.sourcepackagename)])
- expected = [SourceOverride(
- spph.sourcepackagerelease.sourcepackagename,
- component=spph.component, section=spph.section)]
+ {spph.sourcepackagerelease.sourcepackagename: SourceOverride()})
+ expected = {
+ spph.sourcepackagerelease.sourcepackagename: SourceOverride(
+ component=spph.component, section=spph.section)}
self.assertEqual(expected, overrides)
def test_source_overrides_latest_only_is_returned(self):
@@ -75,10 +75,10 @@
policy = FromExistingOverridePolicy()
overrides = policy.calculateSourceOverrides(
spph.distroseries.main_archive, spph.distroseries, spph.pocket,
- [SourceOverride(spn)])
+ {spn: SourceOverride(spn)})
self.assertEqual(
- [SourceOverride(
- spn, component=spph.component, section=spph.section)],
+ {spn: SourceOverride(
+ component=spph.component, section=spph.section)},
overrides)
def test_source_overrides_constant_query_count(self):
@@ -99,7 +99,7 @@
with StormStatementRecorder() as recorder:
policy.calculateSourceOverrides(
spph.distroseries.main_archive, spph.distroseries,
- spph.pocket, [SourceOverride(spn) for spn in spns])
+ spph.pocket, dict((spn, SourceOverride()) for spn in spns))
self.assertThat(recorder, HasQueryCount(Equals(4)))
def test_no_binary_overrides(self):
@@ -113,8 +113,8 @@
policy = FromExistingOverridePolicy()
overrides = policy.calculateBinaryOverrides(
distroseries.main_archive, distroseries, pocket,
- [BinaryOverride(bpn, None)])
- self.assertEqual([], overrides)
+ {(bpn, None): BinaryOverride()})
+ self.assertEqual({}, overrides)
def test_binary_overrides(self):
# When a binary is published in the given distroarchseries, the
@@ -130,26 +130,41 @@
policy = FromExistingOverridePolicy()
overrides = policy.calculateBinaryOverrides(
distroseries.main_archive, distroseries, bpph1.pocket,
- [BinaryOverride(
- bpph1.binarypackagerelease.binarypackagename,
- bpph1.distroarchseries.architecturetag),
- BinaryOverride(
- bpph2.binarypackagerelease.binarypackagename,
- bpph2.distroarchseries.architecturetag),
- ])
- expected = [
- BinaryOverride(
- bpph1.binarypackagerelease.binarypackagename,
- bpph1.distroarchseries.architecturetag,
- component=bpph1.component, section=bpph1.section,
- priority=bpph1.priority),
- BinaryOverride(
- bpph2.binarypackagerelease.binarypackagename,
- bpph2.distroarchseries.architecturetag,
- component=bpph2.component, section=bpph2.section,
- priority=bpph2.priority),
- ]
- self.assertContentEqual(expected, overrides)
+ {(bpph1.binarypackagerelease.binarypackagename,
+ bpph1.distroarchseries.architecturetag): BinaryOverride(),
+ (bpph2.binarypackagerelease.binarypackagename,
+ bpph2.distroarchseries.architecturetag): BinaryOverride(),
+ })
+ expected = {
+ (bpph1.binarypackagerelease.binarypackagename,
+ bpph1.distroarchseries.architecturetag):
+ BinaryOverride(
+ component=bpph1.component, section=bpph1.section,
+ priority=bpph1.priority),
+ (bpph2.binarypackagerelease.binarypackagename,
+ bpph2.distroarchseries.architecturetag):
+ BinaryOverride(
+ component=bpph2.component, section=bpph2.section,
+ priority=bpph2.priority),
+ }
+ self.assertEqual(expected, overrides)
+
+ def test_binary_overrides_skips_unknown_arch(self):
+ # If calculateBinaryOverrides is passed with an archtag that
+ # does not correspond to an ArchSeries of the distroseries,
+ # an empty list is returned.
+ distroseries = self.factory.makeDistroSeries()
+ das = self.factory.makeDistroArchSeries(
+ architecturetag='amd64',
+ distroseries=distroseries)
+ distroseries.nominatedarchindep = das
+ bpn = self.factory.makeBinaryPackageName()
+ pocket = self.factory.getAnyPocket()
+ policy = FromExistingOverridePolicy()
+ overrides = policy.calculateBinaryOverrides(
+ distroseries.main_archive, distroseries, pocket,
+ {(bpn, 'i386'): BinaryOverride()})
+ self.assertEqual({}, overrides)
def test_binary_overrides_constant_query_count(self):
# The query count is constant, no matter how many bpn-das pairs are
@@ -171,7 +186,7 @@
with StormStatementRecorder() as recorder:
policy.calculateBinaryOverrides(
distroseries.main_archive, distroseries, pocket,
- [BinaryOverride(bpn, das) for bpn, das in bpns])
+ dict(((bpn, das), BinaryOverride()) for bpn, das in bpns))
self.assertThat(recorder, HasQueryCount(Equals(4)))
@@ -214,13 +229,16 @@
overrides = UnknownOverridePolicy().calculateSourceOverrides(
distroseries.main_archive, distroseries,
PackagePublishingPocket.RELEASE,
- [SourceOverride(
- spn, component=getUtility(IComponentSet)[component])
- for spn, component in zip(spns, ('main', 'contrib', 'non-free'))])
- expected = [
- SourceOverride(spn, component=getUtility(IComponentSet)[component])
+ dict(
+ (spn, SourceOverride(
+ component=getUtility(IComponentSet)[component]))
+ for spn, component in
+ zip(spns, ('main', 'contrib', 'non-free'))))
+ expected = dict(
+ (spn, SourceOverride(
+ component=getUtility(IComponentSet)[component]))
for spn, component in
- zip(spns, ('universe', 'multiverse', 'multiverse'))]
+ zip(spns, ('universe', 'multiverse', 'multiverse')))
self.assertEqual(expected, overrides)
def test_unknown_sources_ppa(self):
@@ -233,12 +251,15 @@
overrides = UnknownOverridePolicy().calculateSourceOverrides(
self.factory.makeArchive(distribution=distroseries.distribution),
distroseries, PackagePublishingPocket.RELEASE,
- [SourceOverride(
- spn, component=getUtility(IComponentSet)[component])
- for spn, component in zip(spns, ('main', 'contrib', 'non-free'))])
- expected = [
- SourceOverride(spn, component=getUtility(IComponentSet)[component])
- for spn, component in zip(spns, ('main', 'main', 'main'))]
+ dict(
+ (spn, SourceOverride(
+ component=getUtility(IComponentSet)[component]))
+ for spn, component in
+ zip(spns, ('main', 'contrib', 'non-free'))))
+ expected = dict(
+ (spn, SourceOverride(
+ component=getUtility(IComponentSet)[component]))
+ for spn, component in zip(spns, ('main', 'main', 'main')))
self.assertEqual(expected, overrides)
def test_unknown_binaries(self):
@@ -250,13 +271,12 @@
policy = UnknownOverridePolicy()
overrides = policy.calculateBinaryOverrides(
distroseries.main_archive, distroseries, bpph.pocket,
- [BinaryOverride(
- bpph.binarypackagerelease.binarypackagename, None)])
+ {(bpph.binarypackagerelease.binarypackagename, None):
+ BinaryOverride()})
universe = getUtility(IComponentSet)['universe']
- expected = [
- BinaryOverride(
- bpph.binarypackagerelease.binarypackagename, None,
- component=universe)]
+ expected = {
+ (bpph.binarypackagerelease.binarypackagename, None):
+ BinaryOverride(component=universe)}
self.assertEqual(expected, overrides)
@@ -269,7 +289,7 @@
# policy.
universe = getUtility(IComponentSet)['universe']
spns = [self.factory.makeSourcePackageName()]
- expected = [SourceOverride(spns[0], component=universe)]
+ expected = {spns[0]: SourceOverride(component=universe)}
distroseries = self.factory.makeDistroSeries()
pocket = self.factory.getAnyPocket()
for i in xrange(8):
@@ -277,23 +297,16 @@
distroseries=distroseries, archive=distroseries.main_archive,
pocket=pocket)
spns.append(spph.sourcepackagerelease.sourcepackagename)
- expected.append(
- SourceOverride(
- spph.sourcepackagerelease.sourcepackagename,
- component=spph.component, section=spph.section))
+ expected[spph.sourcepackagerelease.sourcepackagename] = (
+ SourceOverride(component=spph.component, section=spph.section))
spns.append(self.factory.makeSourcePackageName())
- expected.append(
- SourceOverride(spns[-1], component=universe, section=None))
+ expected[spns[-1]] = SourceOverride(component=universe)
policy = UbuntuOverridePolicy()
overrides = policy.calculateSourceOverrides(
distroseries.main_archive, distroseries, pocket,
- [SourceOverride(spn) for spn in spns])
+ dict((spn, SourceOverride()) for spn in spns))
self.assertEqual(10, len(overrides))
- sorted_expected = sorted(
- expected, key=attrgetter("source_package_name.name"))
- sorted_overrides = sorted(
- overrides, key=attrgetter("source_package_name.name"))
- self.assertEqual(sorted_expected, sorted_overrides)
+ self.assertEqual(expected, overrides)
def test_ubuntu_override_policy_binaries(self):
# The Ubuntu policy incorporates both the existing and the unknown
@@ -303,7 +316,7 @@
pocket = self.factory.getAnyPocket()
bpn = self.factory.makeBinaryPackageName()
bpns = []
- expected = []
+ expected = {}
for i in xrange(3):
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries)
@@ -316,47 +329,23 @@
binarypackagerelease=bpr, distroarchseries=distroarchseries,
archive=distroseries.main_archive, pocket=pocket)
bpns.append((bpn, distroarchseries.architecturetag))
- expected.append(
+ expected[(bpn, distroarchseries.architecturetag)] = (
BinaryOverride(
- bpn, distroarchseries.architecturetag,
component=bpph.component, section=bpph.section,
priority=bpph.priority))
for i in xrange(2):
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries)
bpns.append((bpn, distroarchseries.architecturetag))
- expected.append(
- BinaryOverride(
- bpn, distroarchseries.architecturetag, component=universe))
+ expected[bpn, distroarchseries.architecturetag] = BinaryOverride(
+ component=universe)
distroseries.nominatedarchindep = distroarchseries
policy = UbuntuOverridePolicy()
overrides = policy.calculateBinaryOverrides(
distroseries.main_archive, distroseries, pocket,
- [BinaryOverride(bpn, das) for bpn, das in bpns])
+ dict(((bpn, das), BinaryOverride()) for bpn, das in bpns))
self.assertEqual(5, len(overrides))
- key = attrgetter(
- "binary_package_name.name", "architecture_tag", "component.name")
- sorted_expected = sorted(expected, key=key)
- sorted_overrides = sorted(overrides, key=key)
- self.assertEqual(sorted_expected, sorted_overrides)
-
- def test_calculateBinaryOverrides_skips_unknown_arch(self):
- # If calculateBinaryOverrides is passed with an archtag that
- # does not correspond to an ArchSeries of the distroseries,
- # an empty list is returned.
- distroseries = self.factory.makeDistroSeries()
- das = self.factory.makeDistroArchSeries(
- architecturetag='amd64',
- distroseries=distroseries)
- distroseries.nominatedarchindep = das
- bpn = self.factory.makeBinaryPackageName()
- pocket = self.factory.getAnyPocket()
- policy = FromExistingOverridePolicy()
- overrides = policy.calculateBinaryOverrides(
- distroseries.main_archive, distroseries, pocket,
- [BinaryOverride(bpn, 'i386')])
-
- self.assertEqual([], overrides)
+ self.assertEqual(expected, overrides)
def test_phased_update_percentage(self):
# A policy with a phased_update_percentage applies it to new binary
@@ -366,7 +355,7 @@
pocket = self.factory.getAnyPocket()
bpn = self.factory.makeBinaryPackageName()
bpns = []
- expected = []
+ expected = {}
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries)
bpb = self.factory.makeBinaryPackageBuild(
@@ -377,26 +366,18 @@
binarypackagerelease=bpr, distroarchseries=distroarchseries,
archive=distroseries.main_archive, pocket=pocket)
bpns.append((bpn, distroarchseries.architecturetag))
- expected.append(
- BinaryOverride(
- bpn, distroarchseries.architecturetag,
- component=bpph.component, section=bpph.section,
- priority=bpph.priority, phased_update_percentage=50))
+ expected[(bpn, distroarchseries.architecturetag)] = BinaryOverride(
+ component=bpph.component, section=bpph.section,
+ priority=bpph.priority, phased_update_percentage=50)
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries)
bpns.append((bpn, distroarchseries.architecturetag))
- expected.append(
- BinaryOverride(
- bpn, distroarchseries.architecturetag, component=universe,
- phased_update_percentage=50))
+ expected[(bpn, distroarchseries.architecturetag)] = BinaryOverride(
+ component=universe, phased_update_percentage=50)
distroseries.nominatedarchindep = distroarchseries
policy = UbuntuOverridePolicy(phased_update_percentage=50)
overrides = policy.calculateBinaryOverrides(
distroseries.main_archive, distroseries, pocket,
- [BinaryOverride(bpn, das) for bpn, das in bpns])
+ dict(((bpn, das), BinaryOverride()) for bpn, das in bpns))
self.assertEqual(2, len(overrides))
- key = attrgetter(
- "binary_package_name.name", "architecture_tag", "component.name")
- sorted_expected = sorted(expected, key=key)
- sorted_overrides = sorted(overrides, key=key)
- self.assertEqual(sorted_expected, sorted_overrides)
+ self.assertEqual(expected, overrides)
=== modified file 'lib/lp/soyuz/model/packagecopyjob.py'
--- lib/lp/soyuz/model/packagecopyjob.py 2014-07-17 11:04:01 +0000
+++ lib/lp/soyuz/model/packagecopyjob.py 2014-07-21 05:57:28 +0000
@@ -488,10 +488,8 @@
def getSourceOverride(self):
"""Fetch an `ISourceOverride` from the metadata."""
- name = self.package_name
component_name = self.component_name
section_name = self.section_name
- source_package_name = getUtility(ISourcePackageNameSet)[name]
try:
component = getUtility(IComponentSet)[component_name]
except NotFoundError:
@@ -501,8 +499,7 @@
except NotFoundError:
section = None
- return SourceOverride(
- source_package_name, component=component, section=section)
+ return SourceOverride(component=component, section=section)
def findSourcePublication(self):
"""Find the appropriate origin `ISourcePackagePublishingHistory`."""
@@ -524,7 +521,7 @@
override_policy = FromExistingOverridePolicy()
ancestry = override_policy.calculateSourceOverrides(
self.target_archive, self.target_distroseries,
- self.target_pocket, [SourceOverride(source_name)])
+ self.target_pocket, {source_name: SourceOverride()})
copy_policy = self.getPolicyImplementation()
@@ -534,8 +531,8 @@
defaults = UnknownOverridePolicy().calculateSourceOverrides(
self.target_archive, self.target_distroseries,
self.target_pocket,
- [SourceOverride(source_name, component=source_component)])
- self.addSourceOverride(defaults[0])
+ {source_name: SourceOverride(component=source_component)})
+ self.addSourceOverride(defaults[source_name])
if auto_approve:
auto_approve = self.target_archive.canAdministerQueue(
self.requester, self.getSourceOverride().component,
@@ -552,7 +549,7 @@
raise SuspendJobException
else:
# Put the existing override in the metadata.
- self.addSourceOverride(ancestry[0])
+ self.addSourceOverride(ancestry[source_name])
if auto_approve:
auto_approve = self.target_archive.canAdministerQueue(
self.requester, self.getSourceOverride().component,
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2014-07-17 11:04:01 +0000
+++ lib/lp/soyuz/model/publishing.py 2014-07-21 05:57:28 +0000
@@ -1479,11 +1479,11 @@
with_overrides = {}
overrides = policy.calculateBinaryOverrides(
archive, distroseries, pocket,
- [BinaryOverride(bpn, archtag)
- for bpn, archtag in bpn_archtag.keys()])
- for override in overrides:
- bpph = bpn_archtag[
- (override.binary_package_name, override.architecture_tag)]
+ dict(
+ ((bpn, archtag), BinaryOverride())
+ for bpn, archtag in bpn_archtag.keys()))
+ for (bpn, archtag), override in overrides.items():
+ bpph = bpn_archtag[(bpn, archtag)]
new_component = override.component or bpph.component
new_section = override.section or bpph.section
new_priority = override.priority or bpph.priority
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2014-07-09 02:42:47 +0000
+++ lib/lp/soyuz/model/queue.py 2014-07-21 05:57:28 +0000
@@ -997,8 +997,7 @@
if copy_job.component_name not in allowed_component_names:
raise QueueAdminUnauthorizedError(
"No rights to override from %s" % copy_job.component_name)
- copy_job.addSourceOverride(SourceOverride(
- copy_job.package_name, new_component, new_section))
+ copy_job.addSourceOverride(SourceOverride(new_component, new_section))
return True
=== modified file 'lib/lp/soyuz/scripts/packagecopier.py'
--- lib/lp/soyuz/scripts/packagecopier.py 2014-07-17 11:04:01 +0000
+++ lib/lp/soyuz/scripts/packagecopier.py 2014-07-21 05:57:28 +0000
@@ -718,17 +718,17 @@
# If no manual overrides were specified and the archive has an
# override policy then use that policy to get overrides.
if override is None and policy is not None:
- package_names = (source.sourcepackagerelease.sourcepackagename,)
# Only one override can be returned so take the first
# element of the returned list.
overrides = policy.calculateSourceOverrides(
archive, series, pocket,
- [SourceOverride(spn) for spn in package_names])
+ {source.sourcepackagerelease.sourcepackagename:
+ SourceOverride()})
# Only one override can be returned so take the first
# element of the returned list.
assert len(overrides) == 1, (
"More than one override encountered, something is wrong.")
- override = overrides[0]
+ override = overrides[source.sourcepackagerelease.sourcepackagename]
source_copy = source.copyTo(
series, pocket, archive, override, create_dsd_job=create_dsd_job,
creator=creator, sponsor=sponsor, packageupload=packageupload)
=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2014-07-18 07:26:57 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2014-07-21 05:57:28 +0000
@@ -1364,9 +1364,8 @@
dsp = self.factory.makeDistroSeriesParent()
target_archive = dsp.derived_series.main_archive
override = SourceOverride(
- source.sourcepackagerelease.sourcepackagename,
- self.factory.makeComponent(),
- self.factory.makeSection())
+ component=self.factory.makeComponent(),
+ section=self.factory.makeSection())
getUtility(ISourcePackageFormatSelectionSet).add(
dsp.derived_series, SourcePackageFormat.FORMAT_1_0)
switch_dbuser('archivepublisher')
=== modified file 'lib/lp/soyuz/tests/test_packagecopyjob.py'
--- lib/lp/soyuz/tests/test_packagecopyjob.py 2014-07-17 11:04:01 +0000
+++ lib/lp/soyuz/tests/test_packagecopyjob.py 2014-07-21 05:57:28 +0000
@@ -805,7 +805,7 @@
# Publish a package in the source archive with some overridable
# properties set to known values.
- source_package = self.publisher.getPubSource(
+ self.publisher.getPubSource(
distroseries=self.distroseries, sourcename="copyme",
component='universe', section='web',
version="2.8-1", status=PackagePublishingStatus.PUBLISHED,
@@ -829,11 +829,9 @@
switch_dbuser("launchpad_main")
# Add some overrides to the job.
- package = source_package.sourcepackagerelease.sourcepackagename
restricted = getUtility(IComponentSet)['restricted']
editors = getUtility(ISectionSet)['editors']
- override = SourceOverride(
- package, component=restricted, section=editors)
+ override = SourceOverride(component=restricted, section=editors)
job.addSourceOverride(override)
# Accept the upload to release the job then run it.
@@ -1499,14 +1497,12 @@
def test_addSourceOverride(self):
# Test the addOverride method which adds an ISourceOverride to the
# metadata.
- name = self.factory.makeSourcePackageName()
component = self.factory.makeComponent()
section = self.factory.makeSection()
pcj = self.factory.makePlainPackageCopyJob()
switch_dbuser('copy_packages')
- override = SourceOverride(
- source_package_name=name, component=component, section=section)
+ override = SourceOverride(component=component, section=section)
pcj.addSourceOverride(override)
metadata_component = getUtility(
@@ -1526,10 +1522,9 @@
old_component = self.factory.makeComponent()
old_section = self.factory.makeSection()
pcj.addSourceOverride(SourceOverride(
- pcj.package_name, component=old_component, section=old_section))
+ component=old_component, section=old_section))
new_section = self.factory.makeSection()
- pcj.addSourceOverride(SourceOverride(
- pcj.package_name, section=new_section))
+ pcj.addSourceOverride(SourceOverride(section=new_section))
self.assertEqual(old_component.name, pcj.component_name)
self.assertEqual(new_section.name, pcj.section_name)
@@ -1541,10 +1536,9 @@
old_component = self.factory.makeComponent()
old_section = self.factory.makeSection()
pcj.addSourceOverride(SourceOverride(
- pcj.package_name, component=old_component, section=old_section))
+ component=old_component, section=old_section))
new_component = self.factory.makeComponent()
- pcj.addSourceOverride(SourceOverride(
- pcj.package_name, component=new_component))
+ pcj.addSourceOverride(SourceOverride(component=new_component))
self.assertEqual(new_component.name, pcj.component_name)
self.assertEqual(old_section.name, pcj.section_name)
@@ -1558,7 +1552,7 @@
package_name=name.name, package_version="1.0")
switch_dbuser('copy_packages')
- override = SourceOverride(name, component=component, section=section)
+ override = SourceOverride(component=component, section=section)
pcj.addSourceOverride(override)
self.assertEqual(override, pcj.getSourceOverride())
=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
--- lib/lp/soyuz/tests/test_packageupload.py 2014-07-01 02:01:54 +0000
+++ lib/lp/soyuz/tests/test_packageupload.py 2014-07-21 05:57:28 +0000
@@ -523,7 +523,7 @@
upload, pcj = self.makeUploadWithPackageCopyJob(sourcepackagename=spn)
component = self.factory.makeComponent()
section = self.factory.makeSection()
- pcj.addSourceOverride(SourceOverride(spn, component, section))
+ pcj.addSourceOverride(SourceOverride(component, section))
self.assertEqual(component.name, upload.component_name)
def test_displayname_is_package_name(self):
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2014-07-08 06:34:13 +0000
+++ lib/lp/testing/factory.py 2014-07-21 05:57:28 +0000
@@ -3446,8 +3446,7 @@
target_archive=distroseries.main_archive,
target_distroseries=distroseries, requester=requester,
include_binaries=include_binaries)
- job.addSourceOverride(SourceOverride(
- spr.sourcepackagename, spr.component, spr.section))
+ job.addSourceOverride(SourceOverride(spr.component, spr.section))
try:
job.run()
except SuspendJobException:
Follow ups