iter_pkg: Refactor nuninst cloning

Move nuninst cloning out of the check loop and always populate the new
nuninst entirely.

This will allow some simplifications in other places.

Signed-off-by: Niels Thykier <niels@thykier.net>
debian
Niels Thykier 11 years ago
parent 0043b09c45
commit da83e4cc23

@ -2291,9 +2291,9 @@ class Britney(object):
position = len(packages) position = len(packages)
if nuninst: if nuninst:
nuninst_comp = nuninst.copy() nuninst_comp = nuninst
else: else:
nuninst_comp = self.nuninst_orig.copy() nuninst_comp = self.nuninst_orig
# local copies for better performance # local copies for better performance
binaries = self.binaries['testing'] binaries = self.binaries['testing']
@ -2332,17 +2332,35 @@ class Britney(object):
self.output_write("trying: %s\n" % (item.uvname)) self.output_write("trying: %s\n" % (item.uvname))
better = True better = True
nuninst = {}
# apply the changes # apply the changes
affected, undo = self.doop_source(item, lundo) affected, undo = self.doop_source(item, lundo)
# check the affected packages on all the architectures # Copy nuninst_comp - we have to deep clone affected
for arch in (item.architecture == 'source' and architectures or (item.architecture,)): # architectures.
check_archall = arch in nobreakall_arches
# NB: We do this *after* updating testing and we have to filter out
# removed binaries. Otherwise, uninstallable binaries that were
# removed by the item would still be counted.
if item.architecture == 'source':
# Assume that all architectures are affected and deep
# copy nuninst_comp
nuninst = {}
for arch in architectures:
nuninst[arch] = set(x for x in nuninst_comp[arch] if x in binaries[arch][0]) nuninst[arch] = set(x for x in nuninst_comp[arch] if x in binaries[arch][0])
nuninst[arch + "+all"] = set(x for x in nuninst_comp[arch + "+all"] if x in binaries[arch][0]) nuninst[arch + "+all"] = set(x for x in nuninst_comp[arch + "+all"] if x in binaries[arch][0])
else:
# Shallow clone nuninst_comp except for the affected
# architecture, which is deep cloned.
arch = item.architecture
nuninst = nuninst_comp.copy()
nuninst[arch] = set(x for x in nuninst_comp[arch] if x in binaries[arch][0])
nuninst[arch + "+all"] = set(x for x in nuninst_comp[arch + "+all"] if x in binaries[arch][0])
# check the affected packages on all the architectures
for arch in (item.architecture == 'source' and architectures or (item.architecture,)):
check_archall = arch in nobreakall_arches
check_packages(arch, affected, check_archall, nuninst) check_packages(arch, affected, check_archall, nuninst)
@ -2368,8 +2386,7 @@ class Britney(object):
self.output_write(" all: %s\n" % (" ".join( x.uvname for x in selected ))) self.output_write(" all: %s\n" % (" ".join( x.uvname for x in selected )))
else: else:
self.output_write(" most: (%d) .. %s\n" % (len(selected), " ".join(x.uvname for x in selected[-20:]))) self.output_write(" most: (%d) .. %s\n" % (len(selected), " ".join(x.uvname for x in selected[-20:])))
for k in nuninst: nuninst_comp = nuninst
nuninst_comp[k] = nuninst[k]
else: else:
self.output_write("skipped: %s (%d <- %d)\n" % (item.uvname, len(extra), len(packages))) self.output_write("skipped: %s (%d <- %d)\n" % (item.uvname, len(extra), len(packages)))
self.output_write(" got: %s\n" % (self.eval_nuninst(nuninst, item.architecture != 'source' and nuninst_comp or None))) self.output_write(" got: %s\n" % (self.eval_nuninst(nuninst, item.architecture != 'source' and nuninst_comp or None)))

Loading…
Cancel
Save