1 |
commit: 5076fa35cdcba5a092f16c2004e90d4d84c01044 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 24 19:05:00 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Sep 24 19:05:00 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5076fa35 |
7 |
|
8 |
portdbapi: move repo loop to _iter_visible |
9 |
|
10 |
This allows use to avoid using a set to eliminate duplicates, since we |
11 |
can break out of the repo loop as soon as a given cpv is found to be |
12 |
visible. |
13 |
|
14 |
--- |
15 |
pym/portage/dbapi/porttree.py | 123 +++++++++++++++++++++------------------- |
16 |
1 files changed, 65 insertions(+), 58 deletions(-) |
17 |
|
18 |
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py |
19 |
index e4cf9a6..aaa69fa 100644 |
20 |
--- a/pym/portage/dbapi/porttree.py |
21 |
+++ b/pym/portage/dbapi/porttree.py |
22 |
@@ -874,22 +874,9 @@ class portdbapi(dbapi): |
23 |
|
24 |
elif level == "match-visible": |
25 |
# find all visible matches |
26 |
- if mydep.repo is not None or len(self.porttrees) == 1: |
27 |
- myval = list(self._iter_visible( |
28 |
- self.xmatch("match-all", mydep), |
29 |
- mytree=mytree)) |
30 |
- else: |
31 |
- myval = set() |
32 |
- # We iterate over self.porttrees, since it's common to |
33 |
- # tweak this attribute in order to adjust match behavior. |
34 |
- for tree in self.porttrees: |
35 |
- repo = self.repositories.get_name_for_location(tree) |
36 |
- myval.update(self._iter_visible( |
37 |
- self.xmatch("match-all", mydep.with_repo(repo)), |
38 |
- mytree=tree)) |
39 |
- myval = list(myval) |
40 |
- if len(myval) > 1: |
41 |
- self._cpv_sort_ascending(myval) |
42 |
+ myval = self.xmatch("match-all", mydep) |
43 |
+ if myval: |
44 |
+ myval = list(self._iter_visible(myval, myrepo=mydep.repo)) |
45 |
|
46 |
elif level == "minimum-all": |
47 |
# Find the minimum matching version. This is optimized to |
48 |
@@ -1016,24 +1003,24 @@ class portdbapi(dbapi): |
49 |
def match(self, mydep, use_cache=1): |
50 |
return self.xmatch("match-visible", mydep) |
51 |
|
52 |
- def gvisible(self, mylist, mytree=None): |
53 |
+ def gvisible(self, mylist): |
54 |
warnings.warn("The 'gvisible' method of " |
55 |
"portage.dbapi.porttree.portdbapi " |
56 |
"is deprecated, and the functionality " |
57 |
"has been combined into the 'visible' method", |
58 |
DeprecationWarning, stacklevel=2) |
59 |
- return self.visible(mylist, mytree=mytree) |
60 |
+ return self.visible(mylist) |
61 |
|
62 |
- def visible(self, cpv_iter, mytree=None): |
63 |
+ def visible(self, cpv_iter): |
64 |
""" |
65 |
Return a list containing only visible packages. |
66 |
""" |
67 |
- if mylist is None: |
68 |
+ if cpv_iter is None: |
69 |
return [] |
70 |
|
71 |
- return list(self._iter_visible(iter(cpv_iter), mytree=mytree)) |
72 |
+ return list(self._iter_visible(iter(cpv_iter))) |
73 |
|
74 |
- def _iter_visible(self, cpv_iter, mytree=None): |
75 |
+ def _iter_visible(self, cpv_iter, myrepo=None): |
76 |
""" |
77 |
Return a new list containing only visible packages. |
78 |
""" |
79 |
@@ -1043,46 +1030,66 @@ class portdbapi(dbapi): |
80 |
chost = self.settings.get('CHOST', '') |
81 |
accept_chost = self.settings._accept_chost |
82 |
getMaskAtom = self.settings._getMaskAtom |
83 |
+ |
84 |
+ if len(self.porttrees) == 1: |
85 |
+ repos = [None] |
86 |
+ elif myrepo is not None: |
87 |
+ repos = [myrepo] |
88 |
+ else: |
89 |
+ # We iterate over self.porttrees, since it's common to |
90 |
+ # tweak this attribute in order to adjust match behavior. |
91 |
+ repos = [] |
92 |
+ for tree in reversed(self.porttrees): |
93 |
+ repos.append(self.repositories.get_name_for_location(tree)) |
94 |
+ |
95 |
for mycpv in cpv_iter: |
96 |
- metadata.clear() |
97 |
- try: |
98 |
- metadata.update(zip(aux_keys, |
99 |
- self.aux_get(mycpv, aux_keys, mytree=mytree))) |
100 |
- except KeyError: |
101 |
- continue |
102 |
- except PortageException as e: |
103 |
- writemsg("!!! Error: aux_get('%s', %s)\n" % (mycpv, aux_keys), |
104 |
- noiselevel=-1) |
105 |
- writemsg("!!! %s\n" % (e,), noiselevel=-1) |
106 |
- del e |
107 |
- continue |
108 |
- eapi = metadata["EAPI"] |
109 |
- if not eapi_is_supported(eapi): |
110 |
- continue |
111 |
- if _eapi_is_deprecated(eapi): |
112 |
- continue |
113 |
- if not metadata["SLOT"]: |
114 |
- continue |
115 |
- if getMaskAtom(mycpv, metadata): |
116 |
- continue |
117 |
- if self.settings._getMissingKeywords(mycpv, metadata): |
118 |
- continue |
119 |
- if local_config: |
120 |
- metadata['CHOST'] = chost |
121 |
- if not accept_chost(mycpv, metadata): |
122 |
- continue |
123 |
- metadata["USE"] = "" |
124 |
- if "?" in metadata["LICENSE"] or "?" in metadata["PROPERTIES"]: |
125 |
- self.doebuild_settings.setcpv(mycpv, mydb=metadata) |
126 |
- metadata['USE'] = self.doebuild_settings['PORTAGE_USE'] |
127 |
+ for repo in repos: |
128 |
+ metadata.clear() |
129 |
try: |
130 |
- if self.settings._getMissingLicenses(mycpv, metadata): |
131 |
+ metadata.update(zip(aux_keys, |
132 |
+ self.aux_get(mycpv, aux_keys, myrepo=repo))) |
133 |
+ except KeyError: |
134 |
+ continue |
135 |
+ except PortageException as e: |
136 |
+ writemsg("!!! Error: aux_get('%s', %s)\n" % |
137 |
+ (mycpv, aux_keys), noiselevel=-1) |
138 |
+ writemsg("!!! %s\n" % (e,), noiselevel=-1) |
139 |
+ del e |
140 |
+ continue |
141 |
+ eapi = metadata["EAPI"] |
142 |
+ if not eapi_is_supported(eapi): |
143 |
+ continue |
144 |
+ if _eapi_is_deprecated(eapi): |
145 |
+ continue |
146 |
+ if not metadata["SLOT"]: |
147 |
+ continue |
148 |
+ if getMaskAtom(mycpv, metadata): |
149 |
+ continue |
150 |
+ if self.settings._getMissingKeywords(mycpv, metadata): |
151 |
+ continue |
152 |
+ if local_config: |
153 |
+ metadata['CHOST'] = chost |
154 |
+ if not accept_chost(mycpv, metadata): |
155 |
continue |
156 |
- if self.settings._getMissingProperties(mycpv, metadata): |
157 |
+ metadata["USE"] = "" |
158 |
+ if "?" in metadata["LICENSE"] or \ |
159 |
+ "?" in metadata["PROPERTIES"]: |
160 |
+ self.doebuild_settings.setcpv(mycpv, mydb=metadata) |
161 |
+ metadata['USE'] = \ |
162 |
+ self.doebuild_settings['PORTAGE_USE'] |
163 |
+ try: |
164 |
+ if self.settings._getMissingLicenses( |
165 |
+ mycpv, metadata): |
166 |
+ continue |
167 |
+ if self.settings._getMissingProperties( |
168 |
+ mycpv, metadata): |
169 |
+ continue |
170 |
+ except InvalidDependString: |
171 |
continue |
172 |
- except InvalidDependString: |
173 |
- continue |
174 |
- yield mycpv |
175 |
+ |
176 |
+ yield mycpv |
177 |
+ # only yield a given cpv once |
178 |
+ break |
179 |
|
180 |
def close_portdbapi_caches(): |
181 |
for i in portdbapi.portdbapi_instances: |