Move the package loop into register_reverses

By moving the package loop inside register_reverses, it will be
invoked a lot less (reducing the overhead of invoking functions).

Signed-off-by: Niels Thykier <niels@thykier.net>
master
Niels Thykier 12 years ago
parent 5c1391da4f
commit 0aa2546956

@ -566,8 +566,7 @@ class Britney(object):
packages[pkg] = dpkg
# loop again on the list of packages to register reverse dependencies and conflicts
for pkg in packages:
register_reverses(pkg, packages, provides, check_doubles=False)
register_reverses(packages, provides, check_doubles=False)
# return a tuple with the list of real and virtual packages
return (packages, provides)
@ -1988,10 +1987,12 @@ class Britney(object):
affected.update(self.get_reverse_tree(binary, parch, 'testing'))
# register reverse dependencies and conflicts for the new binary packages
for p in source[BINARIES]:
binary, parch = p.split("/")
if item.architecture not in ['source', parch]: continue
register_reverses(binary, binaries[parch][0] , binaries[parch][1])
if item.architecture == 'source':
pkg_iter = (p.split("/")[0] for p in source[BINARIES])
else:
ext = "/" + item.architecture
pkg_iter = (p.split("/")[0] for p in source[BINARIES] if p.endswith(ext))
register_reverses(binaries[parch][0], binaries[parch][1], iterator=pkg_iter)
# add/update the source package
if item.architecture == 'source':

@ -163,44 +163,55 @@ def old_libraries_format(libs):
def register_reverses(pkg, packages, provides, check_doubles=True,
def register_reverses(packages, provides, check_doubles=True, iterator=None,
parse_depends=apt_pkg.parse_depends,
DEPENDS=DEPENDS, CONFLICTS=CONFLICTS,
RDEPENDS=RDEPENDS, RCONFLICTS=RCONFLICTS):
"""Register reverse dependencies and conflicts for the specified package
"""Register reverse dependencies and conflicts for a given
sequence of packages
This method registers the reverse dependencies and conflicts for
a given package using `packages` as the list of packages and `provides`
as the list of virtual packages.
This method registers the reverse dependencies and conflicts for a
given sequence of packages. "packages" is a table of real
packages and "provides" is a table of virtual packages.
iterator is the sequence of packages for which the reverse
relations should be updated.
The "X=X" parameters are optimizations to avoid "load global" in
the loops.
"""
# register the list of the dependencies for the depending packages
dependencies = []
if packages[pkg][DEPENDS]:
dependencies.extend(parse_depends(packages[pkg][DEPENDS], False))
# go through the list
for p in dependencies:
for a in p:
# register real packages
if a[0] in packages and (not check_doubles or pkg not in packages[a[0]][RDEPENDS]):
packages[a[0]][RDEPENDS].append(pkg)
# also register packages which provide the package (if any)
if a[0] in provides:
for i in provides.get(a[0]):
if i not in packages: continue
if not check_doubles or pkg not in packages[i][RDEPENDS]:
packages[i][RDEPENDS].append(pkg)
# register the list of the conflicts for the conflicting packages
if packages[pkg][CONFLICTS]:
for p in parse_depends(packages[pkg][CONFLICTS], False):
if iterator is None:
iterator = packages.iterkeys()
else:
iterator = ifilter_only(packages, iterator)
for pkg in iterator:
# register the list of the dependencies for the depending packages
dependencies = []
if packages[pkg][DEPENDS]:
dependencies.extend(parse_depends(packages[pkg][DEPENDS], False))
# go through the list
for p in dependencies:
for a in p:
# register real packages
if a[0] in packages and (not check_doubles or pkg not in packages[a[0]][RCONFLICTS]):
packages[a[0]][RCONFLICTS].append(pkg)
if a[0] in packages and (not check_doubles or pkg not in packages[a[0]][RDEPENDS]):
packages[a[0]][RDEPENDS].append(pkg)
# also register packages which provide the package (if any)
if a[0] in provides:
for i in provides[a[0]]:
if i not in packages: continue
if not check_doubles or pkg not in packages[i][RCONFLICTS]:
packages[i][RCONFLICTS].append(pkg)
if not check_doubles or pkg not in packages[i][RDEPENDS]:
packages[i][RDEPENDS].append(pkg)
# register the list of the conflicts for the conflicting packages
if packages[pkg][CONFLICTS]:
for p in parse_depends(packages[pkg][CONFLICTS], False):
for a in p:
# register real packages
if a[0] in packages and (not check_doubles or pkg not in packages[a[0]][RCONFLICTS]):
packages[a[0]][RCONFLICTS].append(pkg)
# also register packages which provide the package (if any)
if a[0] in provides:
for i in provides[a[0]]:
if i not in packages: continue
if not check_doubles or pkg not in packages[i][RCONFLICTS]:
packages[i][RCONFLICTS].append(pkg)

Loading…
Cancel
Save