From 208c3c2e90b4a52c2fdf6845e5565bd57c1af8bb Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Thu, 9 Aug 2018 15:18:10 +0000 Subject: [PATCH] britney: Use direct and indirect affected packages for nuninst checks Previously, we split affected into a "reverse relations with a dependency on the migrated/change package" set and a set of "the rest". With this commit we change the sets into a set of packages with a direct relation on the migrated/changed package and the full set of all affected. The change has no effect on Britney's results as the first set is only used as an optimization to reject some items faster. Signed-off-by: Niels Thykier --- britney.py | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/britney.py b/britney.py index 5d4af8d..67725da 100755 --- a/britney.py +++ b/britney.py @@ -1979,8 +1979,7 @@ class Britney(object): """ undo = {'binaries': {}, 'sources': {}, 'virtual': {}, 'nvirtual': []} - affected_pos = set() - affected_remain = set() + affected_direct = set() # local copies for better performance source_suite = item.suite @@ -2039,8 +2038,8 @@ class Britney(object): if pkey not in eqv_set: # all the reverse dependencies are affected by # the change - affected_pos.update(inst_tester.reverse_dependencies_of(rm_pkg_id)) - affected_remain.update(inst_tester.negative_dependencies_of(rm_pkg_id)) + affected_direct.update(inst_tester.reverse_dependencies_of(rm_pkg_id)) + affected_direct.update(inst_tester.negative_dependencies_of(rm_pkg_id)) # remove the provided virtual packages for provided_pkg, prov_version, _ in pkg_data.provides: @@ -2066,7 +2065,7 @@ class Britney(object): # obviously, added/modified packages are affected if not equivalent_replacement: - affected_pos.add(updated_pkg_id) + affected_direct.add(updated_pkg_id) # if the binary already exists in testing, it is currently # built by another source package. we therefore remove the # version built by the other source package, after marking @@ -2078,8 +2077,7 @@ class Britney(object): undo['binaries'][key] = old_pkg_id if not equivalent_replacement: # all the reverse conflicts - affected_pos.update(inst_tester.reverse_dependencies_of(old_pkg_id)) - affected_remain.update(inst_tester.negative_dependencies_of(old_pkg_id)) + affected_direct.update(inst_tester.reverse_dependencies_of(old_pkg_id)) inst_tester.remove_testing_binary(old_pkg_id) elif hint_undo: # the binary isn't in testing, but it may have been at @@ -2095,7 +2093,7 @@ class Britney(object): for (tundo, tpkg) in hint_undo: if key in tundo['binaries']: tpkg_id = tundo['binaries'][key] - affected_pos.update(inst_tester.reverse_dependencies_of(tpkg_id)) + affected_direct.update(inst_tester.reverse_dependencies_of(tpkg_id)) # add/update the binary package from the source suite new_pkg_data = packages_s[parch][0][binary] @@ -2112,14 +2110,14 @@ class Britney(object): provides_t_a[provided_pkg].add((binary, prov_version)) if not equivalent_replacement: # all the reverse dependencies are affected by the change - affected_pos.add(updated_pkg_id) - affected_remain.update(inst_tester.negative_dependencies_of(updated_pkg_id)) + affected_direct.add(updated_pkg_id) + affected_direct.update(inst_tester.negative_dependencies_of(updated_pkg_id)) # 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) + affected_all = affected_direct.copy() + compute_reverse_tree(inst_tester, affected_all) # return the package name, the suite, the list of affected packages and the undo dictionary - return (affected_pos, affected_remain, undo) + return (affected_direct, affected_all, undo) def try_migration(self, actions, nuninst_now, lundo=None, automatic_revert=True): is_accepted = True @@ -2136,7 +2134,7 @@ class Britney(object): if len(actions) == 1: item = actions[0] # apply the changes - affected_pos, affected_remain, undo = self.doop_source(item, hint_undo=lundo) + affected_direct, affected_all, undo = self.doop_source(item, hint_undo=lundo) undo_list = [(undo, item)] if item.architecture == 'source': affected_architectures = set(self.options.architectures) @@ -2145,8 +2143,8 @@ class Britney(object): else: undo_list = [] removals = set() - affected_pos = set() - affected_remain = set() + affected_direct = set() + affected_all = set() for item in actions: _, rms, _ = self._compute_groups(item.package, item.suite, item.architecture, @@ -2159,11 +2157,11 @@ class Britney(object): affected_architectures = set(self.options.architectures) for item in actions: - item_affected_pos, item_affected_remain, undo = self.doop_source(item, + item_affected_direct, item_affected_all, undo = self.doop_source(item, hint_undo=lundo, removals=removals) - affected_pos.update(item_affected_pos) - affected_remain.update(item_affected_remain) + affected_direct.update(item_affected_direct) + affected_all.update(item_affected_all) undo_list.append((undo, item)) # Optimise the test if we may revert directly. @@ -2171,10 +2169,9 @@ class Britney(object): # accept the outcome of this migration and expect nuninst to be updated. # (e.g. "force-hint" or "hint") if automatic_revert: - affected_remain -= affected_pos + affected_all -= affected_direct else: - affected_remain |= affected_pos - affected_pos = set() + affected_direct = set() # Copy nuninst_comp - we have to deep clone affected # architectures. @@ -2190,7 +2187,7 @@ class Britney(object): for arch in affected_architectures: check_archall = arch in nobreakall_arches - check_installability(self._inst_tester, packages_t, arch, affected_pos, affected_remain, + check_installability(self._inst_tester, packages_t, arch, affected_direct, affected_all, check_archall, nuninst_after) # if the uninstallability counter is worse than before, break the loop