In --tree output, keep track of which graph edges have already been displayed and...
authorZac Medico <zmedico@gentoo.org>
Sat, 19 May 2007 08:16:59 +0000 (08:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 19 May 2007 08:16:59 +0000 (08:16 -0000)
svn path=/main/trunk/; revision=6556

pym/emerge/__init__.py

index 9fead5459429d80624d4685949d848481465611a..d09aa5615824c25a915f9f3ed1e258cffd27d081 100644 (file)
@@ -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)