Refector depgraph.altlist() reverse/ignore_priority handling.
authorZac Medico <zmedico@gentoo.org>
Tue, 3 Oct 2006 06:45:58 +0000 (06:45 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 3 Oct 2006 06:45:58 +0000 (06:45 -0000)
svn path=/main/trunk/; revision=4578

bin/emerge

index a232744cdbdf21c6e671f74c7015f583471e2bd0..c543913b26aee59e06db15000f42f4a4686f9e3f 100755 (executable)
@@ -1255,25 +1255,15 @@ class depgraph:
        def altlist(self, reversed=False):
                mygraph=self.digraph.copy()
                retlist=[]
+               if reversed:
+                       get_nodes = mygraph.root_nodes
+               else:
+                       get_nodes = mygraph.leaf_nodes
                while not mygraph.empty():
-                       ignore_priority = -1
-                       if reversed:
-                               nodes = mygraph.root_nodes()
-                               if not nodes:
-                                       ignore_priority = digraph.SOFT
-                                       nodes = mygraph.root_nodes(ignore_priority=digraph.SOFT)
-                               if not nodes:
-                                       ignore_priority = digraph.MEDIUM
-                                       nodes = mygraph.root_nodes(ignore_priority=digraph.MEDIUM)
-                       else:
-                               nodes = mygraph.leaf_nodes()
-                               if not nodes:
-                                       ignore_priority = digraph.SOFT
-                                       nodes = mygraph.leaf_nodes(ignore_priority=digraph.SOFT)
-                               if not nodes:
-                                       ignore_priority = digraph.MEDIUM
-                                       nodes = mygraph.leaf_nodes(ignore_priority=digraph.MEDIUM)
-
+                       for ignore_priority in (-1, digraph.SOFT, digraph.MEDIUM):
+                               nodes = get_nodes(ignore_priority=ignore_priority)
+                               if nodes:
+                                       break
                        selected_nodes = None
                        if nodes:
                                if ignore_priority <= digraph.SOFT: