diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-10-24 07:04:32 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-10-24 07:04:32 +0000 |
commit | 08915e3ebccfd05776a772d2b224c9c10c96c3eb (patch) | |
tree | 83f8a644981eda65b9a52dba51c3aea71f77e0f2 /pym/_emerge | |
parent | 65a38c1c30b577f43a9e4f523a0ee857a4786174 (diff) | |
download | portage-08915e3ebccfd05776a772d2b224c9c10c96c3eb.tar.gz portage-08915e3ebccfd05776a772d2b224c9c10c96c3eb.tar.bz2 portage-08915e3ebccfd05776a772d2b224c9c10c96c3eb.zip |
Add a --unordered-display option for use with --tree. This allows the display
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
Diffstat (limited to 'pym/_emerge')
-rw-r--r-- | pym/_emerge/Scheduler.py | 11 | ||||
-rw-r--r-- | pym/_emerge/actions.py | 10 | ||||
-rw-r--r-- | pym/_emerge/depgraph.py | 39 | ||||
-rw-r--r-- | pym/_emerge/main.py | 1 |
4 files changed, 54 insertions, 7 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 69bba4a1b..db1aecc79 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -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" + \ diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index d90ea7b92..f8b5346a6 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -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() diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index a61b9fa78..859bda153 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -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. diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index de3c0f258..9ddbe3df9 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -66,6 +66,7 @@ options=[ "--searchdesc", "--skipfirst", "--tree", +"--unordered-display", "--update", "--verbose", ] |