Refactor doop_source to simplify logic

Cleanly split doop_source into a (small) part about source packages
and a (longer) part about binary packages.

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2016-11-15 22:50:27 +00:00
parent 027142e12b
commit 0f45b195a6

View File

@ -2170,14 +2170,23 @@ class Britney(object):
item.is_removal,
removals=removals)
# remove all binary packages (if the source already exists)
if item.architecture == 'source' or not item.is_removal:
# Handle the source package
if item.architecture == 'source':
if item.package in sources['testing']:
source = sources['testing'][item.package]
undo['sources'][item.package] = source
del sources['testing'][item.package]
else:
# the package didn't exist, so we mark it as to-be-removed in case of undo
undo['sources']['-' + item.package] = True
# add/update the source package
if not item.is_removal:
sources['testing'][item.package] = sources[item.suite][item.package]
# If we are removing *and* updating packages, then check for eqv. packages
if rms and updates:
eqv_table = {}
for rm_pkg_id in rms:
binary, _, parch = rm_pkg_id
key = (binary, parch)
@ -2218,27 +2227,9 @@ class Britney(object):
# finally, remove the binary package
del binaries_t_a[binary]
inst_tester.remove_testing_binary(rm_pkg_id)
# remove the source package
if item.architecture == 'source':
undo['sources'][item.package] = source
del sources['testing'][item.package]
else:
# the package didn't exist, so we mark it as to-be-removed in case of undo
undo['sources']['-' + item.package] = True
# single binary removal; used for clearing up after smooth
# updates but not supported as a manual hint
else:
assert item.package in packages_t[item.architecture][0]
binaries_t_a = packages_t[item.architecture][0]
pkg_id = binaries_t_a[item.package].pkg_id
undo['binaries'][(item.package, item.architecture)] = pkg_id
affected_pos.update(inst_tester.reverse_dependencies_of(pkg_id))
del binaries_t_a[item.package]
inst_tester.remove_testing_binary(pkg_id)
# add the new binary packages (if we are not removing)
if not item.is_removal:
# Add/Update binary packages in testing
if updates:
packages_s = self.binaries[item.suite]
for updated_pkg_id in updates:
@ -2298,10 +2289,6 @@ class Britney(object):
affected_pos.add(updated_pkg_id)
affected_remain.update(inst_tester.negative_dependencies_of(updated_pkg_id))
# add/update the source package
if item.architecture == 'source':
sources['testing'][item.package] = sources[item.suite][item.package]
# Also include the transitive rdeps of the packages found so far
compute_reverse_tree(inst_tester, affected_pos)
compute_reverse_tree(inst_tester, affected_remain)