When selecting packages and there is a mixture of old-style and new-style
authorZac Medico <zmedico@gentoo.org>
Mon, 31 Mar 2008 19:55:56 +0000 (19:55 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 31 Mar 2008 19:55:56 +0000 (19:55 -0000)
virtual matches, filter out the old-style virtual matches.

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

pym/_emerge/__init__.py

index 60cb96e1dfaaba124f27a3fdaade0af9238dad00..848e0e893724ccef0ccb2f93a8ecb903f65149d2 100644 (file)
@@ -1190,7 +1190,7 @@ def iter_atoms(deps):
 class Package(object):
        __slots__ = ("__weakref__", "built", "cpv", "depth",
                "installed", "metadata", "root", "onlydeps", "type_name",
-               "cpv_slot", "slot_atom", "_digraph_node")
+               "cp", "cpv_slot", "slot_atom", "_digraph_node")
        def __init__(self, **kwargs):
                for myattr in self.__slots__:
                        if myattr == "__weakref__":
@@ -1198,9 +1198,8 @@ class Package(object):
                        myvalue = kwargs.get(myattr, None)
                        setattr(self, myattr, myvalue)
 
-               self.slot_atom = "%s:%s" % \
-                       (portage.cpv_getkey(self.cpv), self.metadata["SLOT"])
-
+               self.cp = portage.cpv_getkey(self.cpv)
+               self.slot_atom = "%s:%s" % (self.cp, self.metadata["SLOT"])
                self.cpv_slot = "%s:%s" % (self.cpv, self.metadata["SLOT"])
 
                status = "merge"
@@ -2743,6 +2742,20 @@ class depgraph(object):
                        for pkg in matched_packages:
                                print (pkg.type_name + ":").rjust(10), pkg.cpv
 
+               # Filter out any old-style virtual matches if they are
+               # mixed with new-style virtual matches.
+               cp = portage.dep_getkey(atom)
+               if len(matched_packages) > 1 and \
+                       "virtual" == portage.catsplit(cp)[0]:
+                       for pkg in matched_packages:
+                               if pkg.cp != cp:
+                                       continue
+                               # Got a new-style virtual, so filter
+                               # out any old-style virtuals.
+                               matched_packages = [pkg for pkg in matched_packages \
+                                       if pkg.cp == cp]
+                               break
+
                if len(matched_packages) > 1:
                        bestmatch = portage.best(
                                [pkg.cpv for pkg in matched_packages])