summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-07-02 05:50:46 +0000
committerZac Medico <zmedico@gentoo.org>2007-07-02 05:50:46 +0000
commit9116bff7bac1dacda305eb5926d9df9851f63808 (patch)
tree1db43c6a9698628e84219ee8aa61f371543fceef
parent319a8709009f2d3b994b4405f228fb1a0a59bcab (diff)
downloadportage-9116bff7bac1dacda305eb5926d9df9851f63808.tar.gz
portage-9116bff7bac1dacda305eb5926d9df9851f63808.tar.bz2
portage-9116bff7bac1dacda305eb5926d9df9851f63808.zip
Prefer asap_nodes more aggressively over any other nodes whenever possible. If no asap_nodes can be selected for a given iteration, they will be ignored for the next iteration.
svn path=/main/trunk/; revision=7126
-rw-r--r--pym/emerge/__init__.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py
index b7aedde07..369f68354 100644
--- a/pym/emerge/__init__.py
+++ b/pym/emerge/__init__.py
@@ -2098,20 +2098,25 @@ class depgraph(object):
ignore_priority_soft_range.extend(
xrange(DepPriority.MIN, DepPriority.SOFT + 1))
tree_mode = "--tree" in self.myopts
+ # Tracks whether or not the current iteration should prefer asap_nodes
+ # if available. This is set to False when the previous iteration
+ # failed to select any nodes. It is reset whenever nodes are
+ # successfully selected.
+ prefer_asap = True
while not mygraph.empty():
selected_nodes = None
- if asap_nodes:
+ if prefer_asap and asap_nodes:
"""ASAP nodes are merged before their soft deps."""
- for node in asap_nodes[:]:
- if not mygraph.contains(node):
- asap_nodes.remove(node)
- continue
+ asap_nodes = [node for node in asap_nodes \
+ if mygraph.contains(node)]
+ for node in asap_nodes:
if not mygraph.child_nodes(node,
ignore_priority=DepPriority.SOFT):
selected_nodes = [node]
asap_nodes.remove(node)
break
- if not selected_nodes:
+ if not selected_nodes and \
+ not (prefer_asap and asap_nodes):
for ignore_priority in ignore_priority_soft_range:
nodes = get_nodes(ignore_priority=ignore_priority)
if nodes:
@@ -2155,6 +2160,8 @@ class depgraph(object):
return False
return True
mergeable_nodes = set(nodes)
+ if prefer_asap and asap_nodes:
+ nodes = asap_nodes
for ignore_priority in xrange(DepPriority.SOFT,
DepPriority.MEDIUM_SOFT + 1):
for node in nodes:
@@ -2167,6 +2174,12 @@ class depgraph(object):
if selected_nodes:
break
+ if prefer_asap and asap_nodes and not selected_nodes:
+ # We failed to find any asap nodes to merge, so ignore
+ # them for the next iteration.
+ prefer_asap = False
+ continue
+
if selected_nodes and ignore_priority > DepPriority.SOFT:
# Try to merge ignored medium deps as soon as possible.
for node in selected_nodes:
@@ -2246,6 +2259,10 @@ class depgraph(object):
print "!!! disabling USE flags that trigger optional dependencies."
sys.exit(1)
+ # At this point, we've succeeded in selecting one or more nodes, so
+ # it's now safe to reset the prefer_asap to it's default state.
+ prefer_asap = True
+
for node in selected_nodes:
retlist.append(list(node))
mygraph.remove(node)