1 |
commit: f4f78a6a7c90fb25f2937dba3422774e5f2b535c |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Sep 23 00:53:45 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Sep 23 00:53:45 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f4f78a6a |
7 |
|
8 |
portdbapi: handle multi-repo visiblity |
9 |
|
10 |
This will fix bug #384063. The xmatch list-visible mode was previously |
11 |
used to cache a list of all visible cpvs for a given cp, but this is |
12 |
not useful when there can be duplicate cpvs with different visibility |
13 |
from multiple repos. |
14 |
|
15 |
--- |
16 |
pym/portage/dbapi/porttree.py | 45 ++++++++++++++++++++++++++-------------- |
17 |
1 files changed, 29 insertions(+), 16 deletions(-) |
18 |
|
19 |
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py |
20 |
index af2bca1..7f1bbf0 100644 |
21 |
--- a/pym/portage/dbapi/porttree.py |
22 |
+++ b/pym/portage/dbapi/porttree.py |
23 |
@@ -797,7 +797,7 @@ class portdbapi(dbapi): |
24 |
return mylist |
25 |
|
26 |
def freeze(self): |
27 |
- for x in "bestmatch-visible", "cp-list", "list-visible", "match-all", \ |
28 |
+ for x in "bestmatch-visible", "cp-list", "match-all", \ |
29 |
"match-all-cpv-only", "match-visible", "minimum-all", \ |
30 |
"minimum-visible": |
31 |
self.xcache[x]={} |
32 |
@@ -809,6 +809,8 @@ class portdbapi(dbapi): |
33 |
|
34 |
def xmatch(self,level,origdep,mydep=None,mykey=None,mylist=None): |
35 |
"caching match function; very trick stuff" |
36 |
+ if level == "list-visible": |
37 |
+ level = "match-visible" |
38 |
#if no updates are being made to the tree, we can consult our xcache... |
39 |
if self.frozen: |
40 |
try: |
41 |
@@ -846,12 +848,25 @@ class portdbapi(dbapi): |
42 |
myval = match_from_list(mydep, |
43 |
self.cp_list(mykey, mytree=mytree)) |
44 |
|
45 |
- elif level == "list-visible": |
46 |
- #a list of all visible packages, not called directly (just by xmatch()) |
47 |
- #myval = self.visible(self.cp_list(mykey)) |
48 |
+ elif level == "match-visible": |
49 |
+ # find all visible matches |
50 |
+ if mydep.repo is not None or len(self.porttrees) == 1: |
51 |
+ myval = self.gvisible(self.visible( |
52 |
+ self.xmatch("match-all", mydep), |
53 |
+ mytree=mytree), mytree=mytree) |
54 |
+ else: |
55 |
+ myval = set() |
56 |
+ # We iterate over self.porttrees, since it's common to |
57 |
+ # tweak this attribute in order to adjust match behavior. |
58 |
+ for tree in self.porttrees: |
59 |
+ repo = self.repositories.get_name_for_location(tree) |
60 |
+ myval.update(self.gvisible(self.visible( |
61 |
+ self.xmatch("match-all", mydep.with_repo(repo)), |
62 |
+ mytree=tree), mytree=tree)) |
63 |
+ myval = list(myval) |
64 |
+ if len(myval) > 1: |
65 |
+ self._cpv_sort_ascending(myval) |
66 |
|
67 |
- myval = self.gvisible(self.visible( |
68 |
- self.cp_list(mykey, mytree=mytree))) |
69 |
elif level == "minimum-all": |
70 |
# Find the minimum matching version. This is optimized to |
71 |
# minimize the number of metadata accesses (improves performance |
72 |
@@ -927,11 +942,7 @@ class portdbapi(dbapi): |
73 |
#dep match -- find all matches but restrict search to sublist (used in 2nd half of visible()) |
74 |
|
75 |
myval = list(self._iter_match(mydep, mylist)) |
76 |
- elif level == "match-visible": |
77 |
- #dep match -- find all visible matches |
78 |
- #get all visible packages, then get the matching ones |
79 |
- myval = list(self._iter_match(mydep, |
80 |
- self.xmatch("list-visible", mykey, mydep=Atom(mykey), mykey=mykey))) |
81 |
+ |
82 |
elif level == "match-all": |
83 |
#match *all* visible *and* masked packages |
84 |
if mydep == mykey: |
85 |
@@ -952,19 +963,20 @@ class portdbapi(dbapi): |
86 |
def match(self, mydep, use_cache=1): |
87 |
return self.xmatch("match-visible", mydep) |
88 |
|
89 |
- def visible(self, mylist): |
90 |
+ def visible(self, mylist, mytree=None): |
91 |
"""two functions in one. Accepts a list of cpv values and uses the package.mask *and* |
92 |
packages file to remove invisible entries, returning remaining items. This function assumes |
93 |
that all entries in mylist have the same category and package name.""" |
94 |
if not mylist: |
95 |
return [] |
96 |
|
97 |
- db_keys = ["SLOT"] |
98 |
+ db_keys = ["repository", "SLOT"] |
99 |
visible = [] |
100 |
getMaskAtom = self.settings._getMaskAtom |
101 |
for cpv in mylist: |
102 |
try: |
103 |
- metadata = dict(zip(db_keys, self.aux_get(cpv, db_keys))) |
104 |
+ metadata = dict(zip(db_keys, |
105 |
+ self.aux_get(cpv, db_keys, mytree=mytree))) |
106 |
except KeyError: |
107 |
# masked by corruption |
108 |
continue |
109 |
@@ -975,7 +987,7 @@ class portdbapi(dbapi): |
110 |
visible.append(cpv) |
111 |
return visible |
112 |
|
113 |
- def gvisible(self,mylist): |
114 |
+ def gvisible(self, mylist, mytree=None): |
115 |
"strip out group-masked (not in current group) entries" |
116 |
|
117 |
if mylist is None: |
118 |
@@ -989,7 +1001,8 @@ class portdbapi(dbapi): |
119 |
for mycpv in mylist: |
120 |
metadata.clear() |
121 |
try: |
122 |
- metadata.update(zip(aux_keys, self.aux_get(mycpv, aux_keys))) |
123 |
+ metadata.update(zip(aux_keys, |
124 |
+ self.aux_get(mycpv, aux_keys, mytree=mytree))) |
125 |
except KeyError: |
126 |
continue |
127 |
except PortageException as e: |