mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-02-13 23:38:20 +00:00
solver: Merge some loops to reduce nesting level
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
b61e1086bd
commit
af20634b12
@ -146,70 +146,68 @@ class InstallabilitySolver(object):
|
||||
sat_in_testing = self._inst_tester.any_of_these_are_in_the_suite
|
||||
universe = self._universe
|
||||
debug_solver = self.logger.isEnabledFor(logging.DEBUG)
|
||||
for r in rms:
|
||||
for rdep in chain.from_iterable(universe.reverse_dependencies_of(r) for r in rms):
|
||||
# The binaries have reverse dependencies in testing;
|
||||
# check if we can/should migrate them first.
|
||||
for rdep in universe.reverse_dependencies_of(r):
|
||||
for depgroup in universe.dependencies_of(rdep):
|
||||
rigid = depgroup - going_out
|
||||
if sat_in_testing(rigid):
|
||||
# (partly) satisfied by testing, assume it is okay
|
||||
for depgroup in universe.dependencies_of(rdep):
|
||||
rigid = depgroup - going_out
|
||||
if sat_in_testing(rigid):
|
||||
# (partly) satisfied by testing, assume it is okay
|
||||
continue
|
||||
if rdep in ptable:
|
||||
other = ptable[rdep]
|
||||
if other == key:
|
||||
# "Self-dependency" => ignore
|
||||
continue
|
||||
if rdep in ptable:
|
||||
other = ptable[rdep]
|
||||
if other == key:
|
||||
# "Self-dependency" => ignore
|
||||
continue
|
||||
if debug_solver and other not in order[key]['after']: # pragma: no cover
|
||||
self.logger.debug("Removal induced order: %s before %s", key, other)
|
||||
order[key]['after'].add(other)
|
||||
order[other]['before'].add(key)
|
||||
if debug_solver and other not in order[key]['after']: # pragma: no cover
|
||||
self.logger.debug("Removal induced order: %s before %s", key, other)
|
||||
order[key]['after'].add(other)
|
||||
order[other]['before'].add(key)
|
||||
|
||||
def _compute_group_order_adds(self, adds, order, key, ptable, going_out, going_in):
|
||||
sat_in_testing = self._inst_tester.any_of_these_are_in_the_suite
|
||||
universe = self._universe
|
||||
debug_solver = self.logger.isEnabledFor(logging.DEBUG)
|
||||
for a in adds:
|
||||
for depgroup in chain.from_iterable(universe.dependencies_of(a) for a in adds):
|
||||
# Check if this item should migrate before others
|
||||
# (e.g. because they depend on a new [version of a]
|
||||
# binary provided by this item).
|
||||
for depgroup in universe.dependencies_of(a):
|
||||
rigid = depgroup - going_out
|
||||
if sat_in_testing(rigid):
|
||||
# (partly) satisfied by testing, assume it is okay
|
||||
continue
|
||||
# okay - we got three cases now.
|
||||
# - "swap" (replace existing binary with a newer version)
|
||||
# - "addition" (add new binary without removing any)
|
||||
# - "removal" (remove binary without providing a new)
|
||||
#
|
||||
# The problem is that only the two latter requires
|
||||
# an ordering. A "swap" (in itself) should not
|
||||
# affect us.
|
||||
other_adds = set()
|
||||
other_rms = set()
|
||||
for d in ifilter_only(ptable, depgroup):
|
||||
other = ptable[d]
|
||||
if d in going_in:
|
||||
# "other" provides something "key" needs,
|
||||
# schedule accordingly.
|
||||
other_adds.add(other)
|
||||
else:
|
||||
# "other" removes something "key" needs,
|
||||
# schedule accordingly.
|
||||
other_rms.add(other)
|
||||
rigid = depgroup - going_out
|
||||
if sat_in_testing(rigid):
|
||||
# (partly) satisfied by testing, assume it is okay
|
||||
continue
|
||||
# okay - we got three cases now.
|
||||
# - "swap" (replace existing binary with a newer version)
|
||||
# - "addition" (add new binary without removing any)
|
||||
# - "removal" (remove binary without providing a new)
|
||||
#
|
||||
# The problem is that only the two latter requires
|
||||
# an ordering. A "swap" (in itself) should not
|
||||
# affect us.
|
||||
other_adds = set()
|
||||
other_rms = set()
|
||||
for d in ifilter_only(ptable, depgroup):
|
||||
other = ptable[d]
|
||||
if d in going_in:
|
||||
# "other" provides something "key" needs,
|
||||
# schedule accordingly.
|
||||
other_adds.add(other)
|
||||
else:
|
||||
# "other" removes something "key" needs,
|
||||
# schedule accordingly.
|
||||
other_rms.add(other)
|
||||
|
||||
for other in (other_adds - other_rms):
|
||||
if debug_solver and other != key and other not in order[key]['after']: # pragma: no cover
|
||||
self.logger.debug("Dependency induced order (add): %s before %s", key, other)
|
||||
order[key]['after'].add(other)
|
||||
order[other]['before'].add(key)
|
||||
for other in (other_adds - other_rms):
|
||||
if debug_solver and other != key and other not in order[key]['after']: # pragma: no cover
|
||||
self.logger.debug("Dependency induced order (add): %s before %s", key, other)
|
||||
order[key]['after'].add(other)
|
||||
order[other]['before'].add(key)
|
||||
|
||||
for other in (other_rms - other_adds):
|
||||
if debug_solver and other != key and other not in order[key]['before']: # pragma: no cover
|
||||
self.logger.debug("Dependency induced order (remove): %s before %s", key, other)
|
||||
order[key]['before'].add(other)
|
||||
order[other]['after'].add(key)
|
||||
for other in (other_rms - other_adds):
|
||||
if debug_solver and other != key and other not in order[key]['before']: # pragma: no cover
|
||||
self.logger.debug("Dependency induced order (remove): %s before %s", key, other)
|
||||
order[key]['before'].add(other)
|
||||
order[other]['after'].add(key)
|
||||
|
||||
def _compute_group_order(self, groups, key2item):
|
||||
universe = self._universe
|
||||
|
Loading…
x
Reference in New Issue
Block a user