Optimize the return value of get_reverse_tree

All callers of get_reverse_tree compute the same modification of its
return value, so move that computation into get_reverse_tree.

Signed-off-by: Niels Thykier <niels@thykier.net>
debian
Niels Thykier 13 years ago
parent 94c8b3a411
commit 689204a958

@ -191,6 +191,7 @@ import urllib
import apt_pkg
from functools import reduce, partial
from itertools import chain, repeat
from operator import attrgetter
if __name__ == '__main__':
@ -1891,8 +1892,7 @@ class Britney(object):
# save the old binary for undo
undo['binaries'][p] = binaries[parch][0][binary]
# all the reverse dependencies are affected by the change
affected.update( [ (x, parch) for x in \
self.get_reverse_tree(binary, parch, 'testing') ] )
affected.update(self.get_reverse_tree(binary, parch, 'testing'))
# remove the provided virtual packages
for j in binaries[parch][0][binary][PROVIDES]:
key = j + "/" + parch
@ -1916,8 +1916,7 @@ class Britney(object):
# updates but not supported as a manual hint
elif item.package in binaries[item.architecture][0]:
undo['binaries'][item.package + "/" + item.architecture] = binaries[item.architecture][0][item.package]
affected.update( [ (x, item.architecture) for x in \
self.get_reverse_tree(item.package, item.architecture, 'testing') ] )
affected.update(self.get_reverse_tree(item.package, item.architecture, 'testing'))
del binaries[item.architecture][0][item.package]
self.systems[item.architecture].remove_binary(item.package)
@ -1935,8 +1934,7 @@ class Britney(object):
# save the old binary package
undo['binaries'][p] = binaries[parch][0][binary]
# all the reverse dependencies are affected by the change
affected.update( [ (x, parch) for x in \
self.get_reverse_tree(binary, parch, 'testing') ] )
affected.update(self.get_reverse_tree(binary, parch, 'testing'))
# all the reverse conflicts and their dependency tree are affected by the change
for j in binaries[parch][0][binary][RCONFLICTS]:
key = (j, parch)
@ -1958,8 +1956,7 @@ class Britney(object):
for rdep in tundo['binaries'][p][RDEPENDS]:
if rdep in binaries[parch][0] and rdep not in source[BINARIES]:
affected.add( (rdep, parch) )
affected.update( [ (x, parch) for x in \
self.get_reverse_tree(rdep, parch, 'testing') ] )
affected.update(self.get_reverse_tree(rdep, parch, 'testing'))
# add/update the binary package
binaries[parch][0][binary] = self.binaries[item.suite][parch][0][binary]
self.systems[parch].add_binary(binary, binaries[parch][0][binary][:PROVIDES] + \
@ -1974,8 +1971,7 @@ class Britney(object):
undo['virtual'][key] = binaries[parch][1][j][:]
binaries[parch][1][j].append(binary)
# all the reverse dependencies are affected by the change
affected.update( [ (x, parch) for x in \
self.get_reverse_tree(binary, parch, 'testing') ] )
affected.update(self.get_reverse_tree(binary, parch, 'testing'))
# register reverse dependencies and conflicts for the new binary packages
for p in source[BINARIES]:
@ -2004,9 +2000,9 @@ class Britney(object):
if x in binaries ]
# flatten the list-of-lists, filtering out already handled packages
# in the process
rev_deps = set([ package for sublist in new_rev_deps \
for package in sublist if package not in seen ])
return seen
rev_deps = set([package for package in chain.from_iterable(new_rev_deps) \
if package not in seen ])
return zip(seen, repeat(arch))
def get_full_tree(self, pkg, arch, suite):
"""Calculate the full dependency tree for the given package

Loading…
Cancel
Save