From 0ab6d29d199faddc339c63f5b60315de5f184c19 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 19 May 2007 08:16:59 +0000 Subject: [PATCH] In --tree output, keep track of which graph edges have already been displayed and try not to display a given edge more than once. svn path=/main/trunk/; revision=6556 --- pym/emerge/__init__.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index 9fead5459..d09aa5615 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -2371,6 +2371,7 @@ class depgraph: mygraph = self._parent_child_digraph i = 0 depth = 0 + shown_edges = set() for x in mylist: if "blocks" == x[0]: display_list.append((x, 0, True)) @@ -2385,6 +2386,7 @@ class depgraph: tree_nodes = tree_nodes[:depth] tree_nodes.append(graph_key) display_list.append((x, depth, True)) + shown_edges.add((graph_key, tree_nodes[depth-1])) else: traversed_nodes = set() # prevent endless circles traversed_nodes.add(graph_key) @@ -2397,19 +2399,29 @@ class depgraph: for node in parent_nodes: if node not in traversed_nodes and \ node not in child_nodes: + edge = (current_node, node) + if edge in shown_edges: + continue selected_parent = node break if not selected_parent: # A direct cycle is unavoidable. for node in parent_nodes: if node not in traversed_nodes: + edge = (current_node, node) + if edge in shown_edges: + continue selected_parent = node break if selected_parent: - traversed_nodes.add(selected_parent) - add_parents(selected_parent, False) + edge = (current_node, selected_parent) + if edge not in shown_edges: + traversed_nodes.add(selected_parent) + add_parents(selected_parent, False) display_list.append((list(current_node), len(tree_nodes), ordered)) + if tree_nodes: + shown_edges.add((current_node, tree_nodes[-1])) tree_nodes.append(current_node) tree_nodes = [] add_parents(graph_key, True) -- 2.26.2