Make _compute_group take a migration item instead of 4 parameters

All callers can supply one and currently just unfold it at the
call-site.

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 6 years ago
parent e0c19b3adb
commit ce6a5704fa
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

@ -1487,8 +1487,8 @@ class Britney(object):
res.append("%s-%d" % (arch[0], n)) res.append("%s-%d" % (arch[0], n))
return "%d+%d: %s" % (total, totalbreak, ":".join(res)) return "%d+%d: %s" % (total, totalbreak, ":".join(res))
def _compute_groups(self, source_name, source_suite, migration_architecture, def _compute_groups(self,
is_removal, item,
allow_smooth_updates=True, allow_smooth_updates=True,
removals=frozenset()): removals=frozenset()):
"""Compute the groups of binaries being migrated by item """Compute the groups of binaries being migrated by item
@ -1498,17 +1498,8 @@ class Britney(object):
the removals are smooth updatable. the removals are smooth updatable.
Parameters: Parameters:
* "source_name" is the name of the source package, whose * "item" is a MigrationItem
binaries are migrating. * "allow_smooth_updates" is a boolean determining whether smooth-
* "suite" is the source suite from which the binaries are migrating.
[Same as item.suite, where available]
* "migration_architecture" is the architecture determines
architecture of the migrating binaries (can be "source" for
a "source"-migration, meaning all binaries regardless of
architecture). [Same as item.architecture, where available]
* "is_removal" is a boolean determining if this is a removal
or not [Same as item.is_removal, where available]
* "allow_smooth_updates" is a boolean determing whether smooth-
updates are permitted in this migration. When set to False, updates are permitted in this migration. When set to False,
the "smoothbins" return value will always be the empty set. the "smoothbins" return value will always be the empty set.
Any value that would have been there will now be in "rms" Any value that would have been there will now be in "rms"
@ -1536,6 +1527,8 @@ class Britney(object):
Unlike doop_source, this will not modify any data structure. Unlike doop_source, this will not modify any data structure.
""" """
# local copies for better performances # local copies for better performances
source_name = item.package
source_suite = item.suite
target_suite = self.suite_info.target_suite target_suite = self.suite_info.target_suite
binaries_s = source_suite.binaries binaries_s = source_suite.binaries
binaries_t = target_suite.binaries binaries_t = target_suite.binaries
@ -1546,7 +1539,7 @@ class Britney(object):
smoothbins = set() smoothbins = set()
# remove all binary packages (if the source already exists) # remove all binary packages (if the source already exists)
if migration_architecture == 'source' or not is_removal: if item.architecture == 'source' or not item.is_removal:
sources_t = target_suite.sources sources_t = target_suite.sources
if source_name in sources_t: if source_name in sources_t:
source_data = sources_t[source_name] source_data = sources_t[source_name]
@ -1557,11 +1550,11 @@ class Britney(object):
# first, build a list of eligible binaries # first, build a list of eligible binaries
for pkg_id in source_data.binaries: for pkg_id in source_data.binaries:
binary, _, parch = pkg_id binary, _, parch = pkg_id
if migration_architecture != 'source' and parch != migration_architecture: if item.architecture != 'source' and parch != item.architecture:
continue continue
# Work around #815995 # Work around #815995
if migration_architecture == 'source' and is_removal and binary not in binaries_t[parch]: if item.architecture == 'source' and item.is_removal and binary not in binaries_t[parch]:
continue continue
# Do not include hijacked binaries # Do not include hijacked binaries
@ -1587,8 +1580,8 @@ class Britney(object):
# the arch-indep packages, but as that's not the case we # the arch-indep packages, but as that's not the case we
# must keep them around; they will not be re-added by the # must keep them around; they will not be re-added by the
# migration so will end up missing from testing # migration so will end up missing from testing
if migration_architecture != 'source' and \ if item.architecture != 'source' and \
source_suite.suite_class.is_additional_source and \ source_suite.suite_class.is_additional_source and \
binaries_t[parch][binary].architecture == 'all': binaries_t[parch][binary].architecture == 'all':
continue continue
else: else:
@ -1597,12 +1590,12 @@ class Britney(object):
# single binary removal; used for clearing up after smooth # single binary removal; used for clearing up after smooth
# updates but not supported as a manual hint # updates but not supported as a manual hint
else: else:
assert source_name in binaries_t[migration_architecture] assert source_name in binaries_t[item.architecture]
pkg_id = binaries_t[migration_architecture][source_name].pkg_id pkg_id = binaries_t[item.architecture][source_name].pkg_id
rms.add(pkg_id) rms.add(pkg_id)
# add the new binary packages (if we are not removing) # add the new binary packages (if we are not removing)
if not is_removal: if not item.is_removal:
source_data = source_suite.sources[source_name] source_data = source_suite.sources[source_name]
source_ver_new = source_data.version source_ver_new = source_data.version
if source_name in sources_t: if source_name in sources_t:
@ -1613,7 +1606,7 @@ class Britney(object):
for pkg_id in source_data.binaries: for pkg_id in source_data.binaries:
binary, ver, parch = pkg_id binary, ver, parch = pkg_id
if migration_architecture not in ['source', parch]: if item.architecture not in ['source', parch]:
continue continue
if binaries_s[parch][binary].source != source_name: if binaries_s[parch][binary].source != source_name:
@ -1622,7 +1615,7 @@ class Britney(object):
# #
# Also, if this isn't a source update, don't remove # Also, if this isn't a source update, don't remove
# the package that's been hijacked if it's present. # the package that's been hijacked if it's present.
if migration_architecture != 'source': if item.architecture != 'source':
for rm_b, rm_v, rm_p in list(rms): for rm_b, rm_v, rm_p in list(rms):
if (rm_b, rm_p) == (binary, parch): if (rm_b, rm_p) == (binary, parch):
rms.remove((rm_b, rm_v, rm_p)) rms.remove((rm_b, rm_v, rm_p))
@ -1674,11 +1667,7 @@ class Britney(object):
pkg_universe = self.pkg_universe pkg_universe = self.pkg_universe
eqv_set = set() eqv_set = set()
updates, rms, _ = self._compute_groups(item.package, updates, rms, _ = self._compute_groups(item, removals=removals)
source_suite,
item.architecture,
item.is_removal,
removals=removals)
# Handle the source package # Handle the source package
if item.architecture == 'source': if item.architecture == 'source':
@ -1834,10 +1823,7 @@ class Britney(object):
affected_direct = set() affected_direct = set()
affected_all = set() affected_all = set()
for item in actions: for item in actions:
_, rms, _ = self._compute_groups(item.package, item.suite, _, rms, _ = self._compute_groups(item, allow_smooth_updates=False)
item.architecture,
item.is_removal,
allow_smooth_updates=False)
removals.update(rms) removals.update(rms)
affected_architectures.add(item.architecture) affected_architectures.add(item.architecture)
@ -1912,7 +1898,7 @@ class Britney(object):
for y in sorted((y for y in packages), key=attrgetter('uvname')): for y in sorted((y for y in packages), key=attrgetter('uvname')):
try: try:
updates, rms, _ = self._compute_groups(y.package, y.suite, y.architecture, y.is_removal) updates, rms, _ = self._compute_groups(y)
result = (y, frozenset(updates), frozenset(rms)) result = (y, frozenset(updates), frozenset(rms))
group_info[y] = result group_info[y] = result
except MigrationConstraintException as e: except MigrationConstraintException as e:

Loading…
Cancel
Save