cpv_expand: avoid old-style virtuals more
authorZac Medico <zmedico@gentoo.org>
Mon, 9 May 2011 20:36:22 +0000 (13:36 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 12 May 2011 05:09:46 +0000 (22:09 -0700)
pym/portage/dbapi/cpv_expand.py

index b77c283f7e946a826b55a30a7fa5aa585350336b..7077b1febee73851011e539e96662221ab8acb20 100644 (file)
@@ -26,7 +26,14 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
                        mykey=myslash[0]+"/"+mysplit[0]
                else:
                        mykey=mycpv
-               if hasattr(mydb, "cp_list") and \
+
+               # Since Gentoo stopped using old-style virtuals in
+               # 2011, typically it's possible to avoid getvirtuals()
+               # calls entirely. Therefore, only call getvirtuals()
+               # if the atom category is "virtual" and cp_list()
+               # returns nothing.
+               if mykey.startswith("virtual/") and \
+                       hasattr(mydb, "cp_list") and \
                        not mydb.cp_list(mykey, use_cache=use_cache):
                                if hasattr(mydb, "vartree"):
                                        settings._populate_treeVirtuals_if_needed(mydb.vartree)