Fix depgraph._serialize_tasks so it never performa a needless uninstall task
authorZac Medico <zmedico@gentoo.org>
Wed, 1 Jul 2009 00:27:38 +0000 (00:27 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 1 Jul 2009 00:27:38 +0000 (00:27 -0000)
when a package in the same slot is scheduled to replace it.

svn path=/main/trunk/; revision=13752

pym/_emerge/depgraph.py

index ee02417d9b8dc049972c2c1b667be25414008165..4f64ec9c7bc6ad00b25e9ebc618f209514564e11 100644 (file)
@@ -2877,28 +2877,16 @@ class depgraph(object):
                                        ignore_priority = priority_range.ignore_priority[i]
                                        nodes = get_nodes(ignore_priority=ignore_priority)
                                        if nodes:
-                                               # If there is a mix of uninstall nodes with other
-                                               # types, save the uninstall nodes for later since
-                                               # sometimes a merge node will render an uninstall
-                                               # node unnecessary (due to occupying the same slot),
-                                               # and we want to avoid executing a separate uninstall
-                                               # task in that case.
+                                               # If there is a mixuture of merges and uninstalls,
+                                               # do the uninstalls first.
                                                if len(nodes) > 1:
                                                        good_uninstalls = []
-                                                       with_some_uninstalls_excluded = []
                                                        for node in nodes:
                                                                if node.operation == "uninstall":
-                                                                       slot_node = self._dynamic_config.mydbapi[node.root
-                                                                               ].match_pkgs(node.slot_atom)
-                                                                       if slot_node and \
-                                                                               slot_node[0].operation == "merge":
-                                                                               continue
                                                                        good_uninstalls.append(node)
-                                                               with_some_uninstalls_excluded.append(node)
+
                                                        if good_uninstalls:
                                                                nodes = good_uninstalls
-                                                       elif with_some_uninstalls_excluded:
-                                                               nodes = with_some_uninstalls_excluded
                                                        else:
                                                                nodes = nodes
 
@@ -3151,6 +3139,17 @@ class depgraph(object):
                                                scheduler_graph.add(blocked_pkg, uninst_task,
                                                        priority=BlockerDepPriority.instance)
 
+                                       # Sometimes a merge node will render an uninstall
+                                       # node unnecessary (due to occupying the same SLOT),
+                                       # and we want to avoid executing a separate uninstall
+                                       # task in that case.
+                                       slot_node = self._dynamic_config.mydbapi[uninst_task.root
+                                               ].match_pkgs(uninst_task.slot_atom)
+                                       if slot_node and \
+                                               slot_node[0].operation == "merge":
+                                               mygraph.add(slot_node[0], uninst_task,
+                                                       priority=BlockerDepPriority.instance)
+
                                        # Reset the state variables for leaf node selection and
                                        # continue trying to select leaf nodes.
                                        prefer_asap = True