For bug #167450, optimize merge order by delaying the merge of root nodes.
authorZac Medico <zmedico@gentoo.org>
Sun, 18 Feb 2007 20:45:14 +0000 (20:45 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 18 Feb 2007 20:45:14 +0000 (20:45 -0000)
svn path=/main/trunk/; revision=5996

pym/emerge/__init__.py

index 96bad676148160ff2e1aabab935e19e27fbd6d49..6d399326678c6201fd29a30fc81e9bdbf84a4b27 100644 (file)
@@ -2025,8 +2025,18 @@ class depgraph:
                                                # output, so it's disabled in reversed mode.
                                                selected_nodes = nodes
                                        else:
-                                               # Only pop one node for optimal merge order.
-                                               selected_nodes = [nodes[0]]
+                                               # For optimal merge order:
+                                               #  * Only pop one node.
+                                               #  * Removing a root node (node without a parent)
+                                               #    will not produce a leaf node, so avoid it.
+                                               for node in nodes:
+                                                       if mygraph.parent_nodes(node):
+                                                               # found a non-root node
+                                                               selected_nodes = [node]
+                                                               break
+                                               if not selected_nodes:
+                                                       # settle for a root node
+                                                       selected_nodes = [nodes[0]]
                                else:
                                        """Recursively gather a group of nodes that RDEPEND on
                                        eachother.  This ensures that they are merged as a group