For bug #165382, don't raise a ValueError in cpv_expand() if there are only two match...
authorZac Medico <zmedico@gentoo.org>
Mon, 5 Feb 2007 20:45:23 +0000 (20:45 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 5 Feb 2007 20:45:23 +0000 (20:45 -0000)
svn path=/main/branches/2.1.2/; revision=5896

pym/portage.py

index d9b283e94c7892a5de3ebd9831f5119c1a3e1321..5c4389c9ca98b3df125b25569d80b60a067ab412 100644 (file)
@@ -4434,8 +4434,18 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
                        for x in settings.categories:
                                if mydb.cp_list(x+"/"+myp,use_cache=use_cache):
                                        matches.append(x+"/"+myp)
-               if (len(matches)>1):
-                       raise ValueError, matches
+               if len(matches) > 1:
+                       if len(matches) == 2:
+                               for x in matches:
+                                       if not x.startswith("virtual/"):
+                                               # Assume that the non-virtual is desired.  This helps
+                                               # avoid the ValueError for invalid deps that come from
+                                               # installed packages (during reverse blocker detection,
+                                               # for example).
+                                               mykey = x
+                                               break
+                       if mykey is None:
+                               raise ValueError, matches
                elif matches:
                        mykey=matches[0]