depgraph: avoid conflicts during _complete_graph
authorZac Medico <zmedico@gentoo.org>
Sun, 28 Jul 2013 23:02:46 +0000 (16:02 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 28 Jul 2013 23:02:46 +0000 (16:02 -0700)
During _complete_graph, it was possible for _select_pkg_from_graph to
make some poor package selections that would result in conflicts when
there were two matches in different slots that conflicted with
eachother.

pym/_emerge/depgraph.py

index 939adde49a59b97ca58ba1de7665d92489e06a65..a7316f0185fdc73660727b5ff8c0d5553a8dc451 100644 (file)
@@ -5084,9 +5084,16 @@ class depgraph(object):
                matches = graph_db.match_pkgs(atom)
                if not matches:
                        return None, None
-               pkg = matches[-1] # highest match
-               in_graph = self._dynamic_config._slot_pkg_map[root].get(pkg.slot_atom)
-               return pkg, in_graph
+
+               # There may be multiple matches, and they may
+               # conflict with eachother, so choose the highest
+               # version that has already been added to the graph.
+               for pkg in reversed(matches):
+                       if pkg in self._dynamic_config.digraph:
+                               return pkg, pkg
+
+               # Fall back to installed packages
+               return self._select_pkg_from_installed(root, atom, onlydeps=onlydeps)
 
        def _select_pkg_from_installed(self, root, atom, onlydeps=False):
                """