From d7afc73681967c64a641d9769dae23886b908164 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 13 Feb 2011 03:13:34 -0800 Subject: [PATCH] depgraph: tweak depth calculation for virtuals Recursively traversed virtual dependencies, and their direct dependencies, are considered to have the same depth as direct dependencies. --- pym/_emerge/depgraph.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 72fc1ae59..1dba229e4 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -1350,8 +1350,10 @@ class depgraph(object): # none visible, so use highest mypriority.satisfied = inst_pkgs[0] + # Dependencies of virtuals are considered to have the + # same depth as the virtual itself. if not self._add_dep(Dependency(atom=atom, - blocker=atom.blocker, child=child, depth=virt_pkg.depth, + blocker=atom.blocker, child=child, depth=virt_dep.depth, parent=virt_pkg, priority=mypriority, root=dep_root), allow_unsatisfied=allow_unsatisfied): return 0 @@ -2184,6 +2186,13 @@ class depgraph(object): if parent is None: selected_atoms = mycheck[1] else: + # Recursively traversed virtual dependencies, and their + # direct dependencies, are considered to have the same + # depth as direct dependencies. + if parent.depth is None: + virt_depth = None + else: + virt_depth = parent.depth + 1 chosen_atom_ids = frozenset(id(atom) for atom in mycheck[1]) selected_atoms = OrderedDict() node_stack = [(parent, None, None)] @@ -2202,9 +2211,10 @@ class depgraph(object): else: # virtuals only have runtime deps node_priority = self._priority(runtime=True) + k = Dependency(atom=parent_atom, blocker=parent_atom.blocker, child=node, - depth=node.depth, parent=node_parent, + depth=virt_depth, parent=node_parent, priority=node_priority, root=node.root) child_atoms = [] @@ -2225,7 +2235,6 @@ class depgraph(object): # record this as an unsatisfied dependency # when necessary. continue - child_node.depth = node.depth + 1 node_stack.append((child_node, node, child_atom)) return selected_atoms -- 2.26.2