Add a --unordered-display option for use with --tree. This allows the display
authorZac Medico <zmedico@gentoo.org>
Sat, 24 Oct 2009 07:04:32 +0000 (07:04 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 24 Oct 2009 07:04:32 +0000 (07:04 -0000)
to be optimized differently since the merge order is not preserved. Thanks
to Sebastian Mingramm (few) for the initial patch. (trunk r14703)

svn path=/main/branches/2.1.7/; revision=14712

man/emerge.1
pym/_emerge/Scheduler.py
pym/_emerge/actions.py
pym/_emerge/depgraph.py
pym/_emerge/main.py

index 8e52b814b17b598bcf2ad17db367c5762bf47448..072635fb32af5c2027f8e3c5a9d5ca4788847f56 100644 (file)
@@ -219,6 +219,12 @@ system.  Its arguments can be \fIatoms\fR or
 \fIebuilds\fR. For a dependency aware version of \fB\-\-unmerge\fR,
 use \fB\-\-depclean\fR or \fB\-\-prune\fR.
 .TP
+.BR "\-\-unordered-display "
+By default the displayed merge list is sorted using the order in
+which the packages will be merged. When \fB\-\-tree\fR is used together 
+with this option, this constraint is removed, hopefully leading to a 
+more readable dependency tree.
+.TP
 .BR "\-\-update " (\fB\-u\fR)
 Updates packages to the best version available, which may not always be the 
 highest version number due to masking for testing and development.
index 69bba4a1bfa814f4008c10b88f4348642989c9b9..db1aecc79a0beb5dafe863082546d5b319355eca 100644 (file)
@@ -1492,9 +1492,14 @@ class Scheduler(PollScheduler):
 
                if self._show_list():
                        if "--tree" in self.myopts:
-                               portage.writemsg_stdout("\n" + \
-                                       darkgreen("These are the packages that " + \
-                                       "would be merged, in reverse order:\n\n"))
+                               if "--unordered-display" in self.myopts:
+                                       portage.writemsg_stdout("\n" + \
+                                               darkgreen("These are the packages that " + \
+                                               "would be merged:") + "\n\n")
+                               else:
+                                       portage.writemsg_stdout("\n" + \
+                                               darkgreen("These are the packages that " + \
+                                               "would be merged, in reverse order:") + "\n\n")
 
                        else:
                                portage.writemsg_stdout("\n" + \
index d90ea7b924d23700aa2f4e38543ab3668478eed5..f8b5346a6ee585499731d4ba1395e35997b908fd 100644 (file)
@@ -176,8 +176,14 @@ def action_build(settings, trees, mtimedb,
                else:
                        action = "merged"
                if "--tree" in myopts and action != "fetched": # Tree doesn't work with fetching
-                       print()
-                       print(darkgreen("These are the packages that would be %s, in reverse order:") % action)
+                       if "--unordered-display" in myopts:
+                               portage.writemsg_stdout("\n" + \
+                                       darkgreen("These are the packages that " + \
+                                       "would be %s:" % action) + "\n\n")
+                       else:
+                               portage.writemsg_stdout("\n" + \
+                                       darkgreen("These are the packages that " + \
+                                       "would be %s, in reverse order:" % action) + "\n\n")
                        print()
                else:
                        print()
index a61b9fa78dd58b6ccd991a0926cb3e97b3624a26..859bda1532dee83680838f1dc0e00f7bb0d19781 100644 (file)
@@ -4534,6 +4534,40 @@ class depgraph(object):
                                for blocker in uninstall_parents:
                                        mygraph.add(upgrade_node, blocker)
 
+               if "--unordered-display" in self._frozen_config.myopts:
+                       display_list = self._unordered_tree_display(mygraph, mylist)
+               else:
+                       display_list = self._ordered_tree_display(mygraph, mylist)
+
+               self._prune_tree_display(display_list)
+
+               return display_list
+
+       def _unordered_tree_display(self, mygraph, mylist):
+               display_list = []
+               seen_nodes = set()
+
+               def print_node(node, depth):
+
+                       if node in seen_nodes:
+                               pass
+                       else:
+                               seen_nodes.add(node)
+
+                               if isinstance(node, Package):
+                                       display_list.append((node, depth, True))
+                               else:
+                                       depth = -1
+
+                               for child_node in mygraph.child_nodes(node):
+                                       print_node(child_node, depth + 1)
+
+               for root_node in mygraph.root_nodes():
+                       print_node(root_node, 0)
+
+               return display_list
+
+       def _ordered_tree_display(self, mygraph, mylist):
                depth = 0
                shown_edges = set()
                tree_nodes = []
@@ -4594,6 +4628,9 @@ class depgraph(object):
                                tree_nodes = []
                                add_parents(x, True)
 
+               return display_list
+
+       def _prune_tree_display(self, display_list):
                last_merge_depth = 0
                for i in range(len(display_list) - 1, -1, -1):
                        node, depth, ordered = display_list[i]
@@ -4613,8 +4650,6 @@ class depgraph(object):
                                depth >= display_list[i+1][1]:
                                        del display_list[i]
 
-               return display_list
-
        def display_problems(self):
                """
                Display problems with the dependency graph such as slot collisions.
index de3c0f2588192c2c8cb92c52582d06891dcbda12..9ddbe3df957e87e679ddab8149153705281307fb 100644 (file)
@@ -66,6 +66,7 @@ options=[
 "--searchdesc",
 "--skipfirst",
 "--tree",
+"--unordered-display",
 "--update",
 "--verbose",
 ]