Make Scheduler._choose_pkg() prefer uninstall operations when available.
authorZac Medico <zmedico@gentoo.org>
Sat, 22 Aug 2009 23:11:23 +0000 (23:11 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 22 Aug 2009 23:11:23 +0000 (23:11 -0000)
svn path=/main/trunk/; revision=14128

pym/_emerge/Scheduler.py

index cbb52448a6d4c3be430a1ba863044e94249ba66e..0de01756e01c73633a2821dcb8b341bf28efcbd5 100644 (file)
@@ -1164,13 +1164,23 @@ class Scheduler(PollScheduler):
                self._prune_digraph()
 
                chosen_pkg = None
-               later = set(self._pkg_queue)
+
+               # Prefer uninstall operations when available.
+               graph = self._digraph
                for pkg in self._pkg_queue:
-                       later.remove(pkg)
-                       if not self._dependent_on_scheduled_merges(pkg, later):
+                       if pkg.operation == 'uninstall' and \
+                               not graph.child_nodes(pkg):
                                chosen_pkg = pkg
                                break
 
+               if chosen_pkg is None:
+                       later = set(self._pkg_queue)
+                       for pkg in self._pkg_queue:
+                               later.remove(pkg)
+                               if not self._dependent_on_scheduled_merges(pkg, later):
+                                       chosen_pkg = pkg
+                                       break
+
                if chosen_pkg is not None:
                        self._pkg_queue.remove(chosen_pkg)