[Piuparts-commits] [SCM] piuparts git repository branch, piatti, updated. 0.44-598-gace668e
Andreas Beckmann
debian at abeckmann.de
Sun May 27 13:47:34 UTC 2012
The following commit has been merged in the piatti branch:
commit 33f196de0cfc4db6341dd36aacf169e08f227351
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Sat Mar 10 12:30:30 2012 +0100
add get_dependency_cycle method
PackagesDB._get_dependency_cycle(self, package)
returns the dependency cycles(s) that contain the given package,
including the package, or [] if the package is not on a cycle
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/piupartslib/packagesdb.py b/piupartslib/packagesdb.py
index 016a5e7..0933948 100644
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@ -295,7 +295,7 @@ class PackagesDB:
self._virtual_packages[provided] = []
self._virtual_packages[provided].append(p["Package"])
- def _get_recursive_dependencies(self, package, break_circles=True):
+ def _get_recursive_dependencies(self, package):
assert self._packages is not None
deps = []
more = package.dependencies()
@@ -308,13 +308,28 @@ class PackagesDB:
more += self._packages[dep].dependencies()
elif dep in self._virtual_packages:
more += self._packages[self._virtual_packages[dep][0]].dependencies()
-
- # Break circular dependencies
- if break_circles and package["Package"] in deps:
- deps.remove(package["Package"])
-
return deps
+ def _get_dependency_cycle(self, package_name):
+ deps = []
+ circular = []
+ more = [package_name]
+ while more:
+ dep = more[0]
+ more = more[1:]
+ if dep not in deps:
+ deps.append(dep)
+ if dep in self._packages:
+ dep_pkg = self._packages[dep]
+ elif dep in self._virtual_packages:
+ dep_pkg = self._packages[self._virtual_packages[dep][0]]
+ else:
+ dep_pkg = None
+ if dep_pkg is not None and package_name in self._get_recursive_dependencies(dep_pkg):
+ circular.append(dep)
+ more += dep_pkg.dependencies()
+ return circular
+
def _compute_package_state(self, package):
if self._logdb.log_exists(package, [self._ok]):
return "successfully-tested"
--
piuparts git repository
More information about the Piuparts-commits
mailing list