Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/
Date: Tue, 03 May 2011 03:02:43
Message-Id: 7edab967a1660094eb3f55fd13679d0939384f27.zmedico@gentoo
1 commit: 7edab967a1660094eb3f55fd13679d0939384f27
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Tue May 3 03:00:54 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Tue May 3 03:01:48 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7edab967
7
8 cpv_expand: avoid old-style virtual code
9
10 This allows portageq calls to avoid loading vdb_metadata.pickle in
11 most cases, which greatly improves performance.
12
13 ---
14 pym/portage/dbapi/cpv_expand.py | 24 ++++++++++--------------
15 1 files changed, 10 insertions(+), 14 deletions(-)
16
17 diff --git a/pym/portage/dbapi/cpv_expand.py b/pym/portage/dbapi/cpv_expand.py
18 index c42e427..9ce0d3d 100644
19 --- a/pym/portage/dbapi/cpv_expand.py
20 +++ b/pym/portage/dbapi/cpv_expand.py
21 @@ -17,8 +17,6 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
22 mysplit = _pkgsplit(myslash[-1])
23 if settings is None:
24 settings = globals()["settings"]
25 - virts = settings.getvirtuals()
26 - virts_p = settings.get_virts_p()
27 if len(myslash)>2:
28 # this is illegal case.
29 mysplit=[]
30 @@ -28,24 +26,21 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
31 mykey=myslash[0]+"/"+mysplit[0]
32 else:
33 mykey=mycpv
34 - if mydb and virts and mykey in virts:
35 - writemsg("mydb.__class__: %s\n" % (mydb.__class__), 1)
36 - if hasattr(mydb, "cp_list"):
37 - if not mydb.cp_list(mykey, use_cache=use_cache):
38 - writemsg("virts[%s]: %s\n" % (str(mykey),virts[mykey]), 1)
39 - mykey_orig = mykey[:]
40 - for vkey in virts[mykey]:
41 + if hasattr(mydb, "cp_list") and \
42 + not mydb.cp_list(mykey, use_cache=use_cache):
43 + virts = settings.getvirtuals().get(mykey)
44 + if virts:
45 + mykey_orig = mykey
46 + for vkey in virts:
47 # The virtuals file can contain a versioned atom, so
48 # it may be necessary to remove the operator and
49 # version from the atom before it is passed into
50 # dbapi.cp_list().
51 if mydb.cp_list(vkey.cp):
52 mykey = str(vkey)
53 - writemsg(_("virts chosen: %s\n") % (mykey), 1)
54 break
55 if mykey == mykey_orig:
56 - mykey = str(virts[mykey][0])
57 - writemsg(_("virts defaulted: %s\n") % (mykey), 1)
58 + mykey = str(virts[0])
59 #we only perform virtual expansion if we are passed a dbapi
60 else:
61 #specific cpv, no category, ie. "foo-1.0"
62 @@ -81,8 +76,9 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
63 mykey=matches[0]
64
65 if not mykey and not isinstance(mydb, list):
66 - if myp in virts_p:
67 - mykey=virts_p[myp][0]
68 + virts_p = settings.get_virts_p().get(myp)
69 + if virts_p:
70 + mykey = virts_p[0]
71 #again, we only perform virtual expansion if we have a dbapi (not a list)
72 if not mykey:
73 mykey="null/"+myp