summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-05-31 01:54:11 +0000
committerZac Medico <zmedico@gentoo.org>2008-05-31 01:54:11 +0000
commit9e2f31bdfdf0a493e4676aa7910dca773ea9001a (patch)
tree7346ebd303d2956ee307165d74e3e2825c218822
parentFix PackageSet.findAtomForPackage() to find the most specific atom since (diff)
downloadportage-multirepo-9e2f31bdfdf0a493e4676aa7910dca773ea9001a.tar.gz
portage-multirepo-9e2f31bdfdf0a493e4676aa7910dca773ea9001a.tar.bz2
portage-multirepo-9e2f31bdfdf0a493e4676aa7910dca773ea9001a.zip
Optimize the new --skipfirst code so that in only has to build
a new depgraph one time when there are unsatisfied deps. This works by recursively traversing the digraph to remove the parent packages whose deps become unsatisfied when their dependencies are pruned from the mergelist. svn path=/main/trunk/; revision=10513
-rw-r--r--pym/_emerge/__init__.py41
1 files changed, 35 insertions, 6 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index dd80c16d..8ae31e50 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -8369,18 +8369,47 @@ def action_build(settings, trees, mtimedb,
while True:
mydepgraph = depgraph(settings, trees,
myopts, myparams, spinner)
+ graph = mydepgraph.digraph
try:
success = mydepgraph.loadResumeCommand(mtimedb["resume"])
except depgraph.UnsatisfiedResumeDep, e:
if "--skipfirst" not in myopts:
raise
- unsatisfied_parents = set(dep.parent for dep in e.value)
- pruned_mergelist = []
- for task in mergelist:
- if isinstance(task, list) and \
- tuple(task) in unsatisfied_parents:
+
+ unsatisfied_parents = dict((dep.parent, dep.parent) \
+ for dep in e.value)
+ traversed_nodes = set()
+ unsatisfied_stack = list(unsatisfied_parents)
+ while unsatisfied_stack:
+ pkg = unsatisfied_stack.pop()
+ if pkg in traversed_nodes:
continue
- pruned_mergelist.append(task)
+ traversed_nodes.add(pkg)
+
+ # If this package was pulled in by a parent
+ # package scheduled for merge, removing this
+ # package may cause the the parent package's
+ # dependency to become unsatisfied.
+ for parent_node in graph.parent_nodes(pkg):
+ if not isinstance(parent_node, Package) \
+ or parent_node.operation != "merge":
+ continue
+ unsatisfied = \
+ graph.child_nodes(parent_node,
+ ignore_priority=DepPriority.SOFT)
+ if pkg in unsatisfied:
+ unsatisfied_parents[parent_node] = parent_node
+ unsatisfied_stack.append(parent_node)
+
+ pruned_mergelist = [x for x in mergelist \
+ if isinstance(x, list) and \
+ tuple(x) not in unsatisfied_parents]
+
+ # It shouldn't happen, but if the size of mergelist
+ # does not decrease for some reason then the loop
+ # will be infinite. Therefore, if that case ever
+ # occurs for some reason, raise the exception to
+ # break out of the loop.
if not pruned_mergelist or \
len(pruned_mergelist) == len(mergelist):
raise