cpv_expand: populate old-style virts on demand
authorZac Medico <zmedico@gentoo.org>
Mon, 9 May 2011 06:23:07 +0000 (23:23 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 12 May 2011 05:09:19 +0000 (22:09 -0700)
If old-style virtuals code is triggered here and we are given a
vartree, use it to avoid creating a temporary instance.

pym/portage/dbapi/cpv_expand.py

index 26f994887419936454ad7a4d3b6158900a014a49..b77c283f7e946a826b55a30a7fa5aa585350336b 100644 (file)
@@ -28,6 +28,8 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
                        mykey=mycpv
                if 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)
                                virts = settings.getvirtuals().get(mykey)
                                if virts:
                                        mykey_orig = mykey
@@ -76,6 +78,8 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
                        mykey=matches[0]
 
                if not mykey and not isinstance(mydb, list):
+                       if hasattr(mydb, "vartree"):
+                               settings._populate_treeVirtuals_if_needed(mydb.vartree)
                        virts_p = settings.get_virts_p().get(myp)
                        if virts_p:
                                mykey = virts_p[0]