1 |
Author: grobian |
2 |
Date: 2010-01-31 09:41:21 +0000 (Sun, 31 Jan 2010) |
3 |
New Revision: 15300 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/bin/egencache |
7 |
main/branches/prefix/pym/portage/__init__.py |
8 |
main/branches/prefix/pym/portage/const.py |
9 |
main/branches/prefix/pym/portage/dbapi/porttree.py |
10 |
Log: |
11 |
Merged from trunk -r15280:15285 |
12 |
|
13 |
| 15281 | Deprecate the first parameter of the portdbapi constructor | |
14 |
| zmedico | since it is always the same as mysettings['PORTDIR']. | |
15 |
|
16 |
| 15282 | Use tuples instead of lists for immutability. | |
17 |
| zmedico | | |
18 |
|
19 |
| 15283 | For immutable config attributes, use shallow copy for speed | |
20 |
| zmedico | and memory conservation. | |
21 |
|
22 |
| 15284 | For immutable config attributes, use shallow copy for speed | |
23 |
| zmedico | and memory conservation. | |
24 |
|
25 |
| 15285 | For immutable config attributes, use shallow copy for speed | |
26 |
| zmedico | and memory conservation. | |
27 |
|
28 |
|
29 |
Modified: main/branches/prefix/bin/egencache |
30 |
=================================================================== |
31 |
--- main/branches/prefix/bin/egencache 2010-01-31 09:40:03 UTC (rev 15299) |
32 |
+++ main/branches/prefix/bin/egencache 2010-01-31 09:41:21 UTC (rev 15300) |
33 |
@@ -326,7 +326,7 @@ |
34 |
|
35 |
settings.lock() |
36 |
|
37 |
- portdb = portage.portdbapi(settings["PORTDIR"], mysettings=settings) |
38 |
+ portdb = portage.portdbapi(mysettings=settings) |
39 |
if options.repo is not None: |
40 |
repo_path = portdb.getRepositoryPath(options.repo) |
41 |
if repo_path is None: |
42 |
|
43 |
Modified: main/branches/prefix/pym/portage/__init__.py |
44 |
=================================================================== |
45 |
--- main/branches/prefix/pym/portage/__init__.py 2010-01-31 09:40:03 UTC (rev 15299) |
46 |
+++ main/branches/prefix/pym/portage/__init__.py 2010-01-31 09:41:21 UTC (rev 15300) |
47 |
@@ -1605,23 +1605,26 @@ |
48 |
self._local_repo_conf_path = None |
49 |
|
50 |
if clone: |
51 |
- self.incrementals = copy.deepcopy(clone.incrementals) |
52 |
- self.profile_path = copy.deepcopy(clone.profile_path) |
53 |
+ # For immutable attributes, use shallow copy for |
54 |
+ # speed and memory conservation. |
55 |
+ self.categories = clone.categories |
56 |
+ self.depcachedir = clone.depcachedir |
57 |
+ self.incrementals = clone.incrementals |
58 |
+ self.module_priority = clone.module_priority |
59 |
+ self.profile_path = clone.profile_path |
60 |
+ self.profiles = clone.profiles |
61 |
+ self.packages = clone.packages |
62 |
+ self.useforce_list = clone.useforce_list |
63 |
+ self.usemask_list = clone.usemask_list |
64 |
+ |
65 |
self.user_profile_dir = copy.deepcopy(clone.user_profile_dir) |
66 |
self.local_config = copy.deepcopy(clone.local_config) |
67 |
self._local_repo_configs = \ |
68 |
copy.deepcopy(clone._local_repo_configs) |
69 |
self._local_repo_conf_path = \ |
70 |
copy.deepcopy(clone._local_repo_conf_path) |
71 |
- |
72 |
- self.module_priority = copy.deepcopy(clone.module_priority) |
73 |
self.modules = copy.deepcopy(clone.modules) |
74 |
- |
75 |
- self.depcachedir = copy.deepcopy(clone.depcachedir) |
76 |
- |
77 |
- self.packages = copy.deepcopy(clone.packages) |
78 |
self.virtuals = copy.deepcopy(clone.virtuals) |
79 |
- |
80 |
self.dirVirtuals = copy.deepcopy(clone.dirVirtuals) |
81 |
self.treeVirtuals = copy.deepcopy(clone.treeVirtuals) |
82 |
self.userVirtuals = copy.deepcopy(clone.userVirtuals) |
83 |
@@ -1630,10 +1633,8 @@ |
84 |
|
85 |
self.use_defs = copy.deepcopy(clone.use_defs) |
86 |
self.usemask = copy.deepcopy(clone.usemask) |
87 |
- self.usemask_list = copy.deepcopy(clone.usemask_list) |
88 |
self.pusemask_list = copy.deepcopy(clone.pusemask_list) |
89 |
self.useforce = copy.deepcopy(clone.useforce) |
90 |
- self.useforce_list = copy.deepcopy(clone.useforce_list) |
91 |
self.puseforce_list = copy.deepcopy(clone.puseforce_list) |
92 |
self.puse = copy.deepcopy(clone.puse) |
93 |
self.make_defaults_use = copy.deepcopy(clone.make_defaults_use) |
94 |
@@ -1655,10 +1656,8 @@ |
95 |
self.lookuplist = self.configlist[:] |
96 |
self.lookuplist.reverse() |
97 |
self._use_expand_dict = copy.deepcopy(clone._use_expand_dict) |
98 |
- self.profiles = copy.deepcopy(clone.profiles) |
99 |
self.backupenv = self.configdict["backupenv"] |
100 |
self.pusedict = copy.deepcopy(clone.pusedict) |
101 |
- self.categories = copy.deepcopy(clone.categories) |
102 |
self.pkeywordsdict = copy.deepcopy(clone.pkeywordsdict) |
103 |
self._pkeywords_list = copy.deepcopy(clone._pkeywords_list) |
104 |
self.pmaskdict = copy.deepcopy(clone.pmaskdict) |
105 |
@@ -1699,14 +1698,16 @@ |
106 |
else: |
107 |
self.profile_path = None |
108 |
else: |
109 |
- self.profile_path = config_profile_path[:] |
110 |
+ self.profile_path = config_profile_path |
111 |
|
112 |
if config_incrementals is None: |
113 |
- self.incrementals = copy.deepcopy(portage.const.INCREMENTALS) |
114 |
+ self.incrementals = portage.const.INCREMENTALS |
115 |
else: |
116 |
- self.incrementals = copy.deepcopy(config_incrementals) |
117 |
+ self.incrementals = config_incrementals |
118 |
+ if not isinstance(self.incrementals, tuple): |
119 |
+ self.incrementals = tuple(self.incrementals) |
120 |
|
121 |
- self.module_priority = ["user","default"] |
122 |
+ self.module_priority = ("user", "default") |
123 |
self.modules = {} |
124 |
modules_loader = portage.env.loaders.KeyValuePairFileLoader( |
125 |
os.path.join(config_root, MODULES_FILE_PATH), None, None) |
126 |
@@ -1784,8 +1785,9 @@ |
127 |
self.profiles.append(custom_prof) |
128 |
del custom_prof |
129 |
|
130 |
+ self.profiles = tuple(self.profiles) |
131 |
self.packages_list = [grabfile_package(os.path.join(x, "packages")) for x in self.profiles] |
132 |
- self.packages = stack_lists(self.packages_list, incremental=1) |
133 |
+ self.packages = tuple(stack_lists(self.packages_list, incremental=1)) |
134 |
del self.packages_list |
135 |
#self.packages = grab_stacked("packages", self.profiles, grabfile, incremental_lines=1) |
136 |
|
137 |
@@ -1808,8 +1810,9 @@ |
138 |
self._pkeywords_list.append(cpdict) |
139 |
|
140 |
# get profile-masked use flags -- INCREMENTAL Child over parent |
141 |
- self.usemask_list = [grabfile(os.path.join(x, "use.mask"), |
142 |
- recursive=1) for x in self.profiles] |
143 |
+ self.usemask_list = tuple( |
144 |
+ tuple(grabfile(os.path.join(x, "use.mask"), recursive=1)) |
145 |
+ for x in self.profiles) |
146 |
self.usemask = set(stack_lists( |
147 |
self.usemask_list, incremental=True)) |
148 |
use_defs_lists = [grabdict(os.path.join(x, "use.defaults")) for x in self.profiles] |
149 |
@@ -1836,8 +1839,9 @@ |
150 |
self.pkgprofileuse.append(cpdict) |
151 |
del rawprofileuse |
152 |
|
153 |
- self.useforce_list = [grabfile(os.path.join(x, "use.force"), |
154 |
- recursive=1) for x in self.profiles] |
155 |
+ self.useforce_list = tuple( |
156 |
+ tuple(grabfile(os.path.join(x, "use.force"), recursive=1)) |
157 |
+ for x in self.profiles) |
158 |
self.useforce = set(stack_lists( |
159 |
self.useforce_list, incremental=True)) |
160 |
|
161 |
|
162 |
Modified: main/branches/prefix/pym/portage/const.py |
163 |
=================================================================== |
164 |
--- main/branches/prefix/pym/portage/const.py 2010-01-31 09:40:03 UTC (rev 15299) |
165 |
+++ main/branches/prefix/pym/portage/const.py 2010-01-31 09:41:21 UTC (rev 15300) |
166 |
@@ -85,26 +85,26 @@ |
167 |
|
168 |
PORTAGE_PACKAGE_ATOM = "sys-apps/portage" |
169 |
|
170 |
-INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", |
171 |
+INCREMENTALS = ("USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", |
172 |
"FEATURES", "ACCEPT_KEYWORDS", |
173 |
"CONFIG_PROTECT_MASK", "CONFIG_PROTECT", |
174 |
"PRELINK_PATH", "PRELINK_PATH_MASK", |
175 |
- "PROFILE_ONLY_VARIABLES"] |
176 |
-EBUILD_PHASES = ["setup", "unpack", "prepare", "configure", |
177 |
+ "PROFILE_ONLY_VARIABLES") |
178 |
+EBUILD_PHASES = ("setup", "unpack", "prepare", "configure", |
179 |
"compile", "test", "install", |
180 |
"package", "preinst", "postinst","prerm", "postrm", |
181 |
- "nofetch", "config", "info", "other"] |
182 |
+ "nofetch", "config", "info", "other") |
183 |
|
184 |
EAPI = 3 |
185 |
|
186 |
HASHING_BLOCKSIZE = 32768 |
187 |
-MANIFEST1_HASH_FUNCTIONS = ["MD5", "SHA256", "RMD160"] |
188 |
-MANIFEST2_HASH_FUNCTIONS = ["SHA1", "SHA256", "RMD160"] |
189 |
+MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160") |
190 |
+MANIFEST2_HASH_FUNCTIONS = ("SHA1", "SHA256", "RMD160") |
191 |
|
192 |
MANIFEST1_REQUIRED_HASH = "MD5" |
193 |
MANIFEST2_REQUIRED_HASH = "SHA1" |
194 |
|
195 |
-MANIFEST2_IDENTIFIERS = ["AUX", "MISC", "DIST", "EBUILD"] |
196 |
+MANIFEST2_IDENTIFIERS = ("AUX", "MISC", "DIST", "EBUILD") |
197 |
# =========================================================================== |
198 |
# END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT |
199 |
# =========================================================================== |
200 |
|
201 |
Modified: main/branches/prefix/pym/portage/dbapi/porttree.py |
202 |
=================================================================== |
203 |
--- main/branches/prefix/pym/portage/dbapi/porttree.py 2010-01-31 09:40:03 UTC (rev 15299) |
204 |
+++ main/branches/prefix/pym/portage/dbapi/porttree.py 2010-01-31 09:41:21 UTC (rev 15300) |
205 |
@@ -141,7 +141,13 @@ |
206 |
def _categories(self): |
207 |
return self.settings.categories |
208 |
|
209 |
- def __init__(self, porttree_root, mysettings=None): |
210 |
+ def __init__(self, _unused_param=None, mysettings=None): |
211 |
+ """ |
212 |
+ @param _unused_param: deprecated |
213 |
+ @type _unused_param: None |
214 |
+ @param mysettings: an immutable config instance |
215 |
+ @type mysettings: portage.config |
216 |
+ """ |
217 |
portdbapi.portdbapi_instances.append(self) |
218 |
|
219 |
from portage import config |
220 |
@@ -151,6 +157,15 @@ |
221 |
from portage import settings |
222 |
self.mysettings = config(clone=settings) |
223 |
|
224 |
+ if _unused_param is not None: |
225 |
+ warnings.warn("The first parameter of the " + \ |
226 |
+ "portage.dbapi.porttree.portdbapi" + \ |
227 |
+ " constructor is now unused. Use " + \ |
228 |
+ "mysettings['PORTDIR'] instead.", |
229 |
+ DeprecationWarning) |
230 |
+ |
231 |
+ porttree_root = self.mysettings['PORTDIR'] |
232 |
+ |
233 |
# This is strictly for use in aux_get() doebuild calls when metadata |
234 |
# is generated by the depend phase. It's safest to use a clone for |
235 |
# this purpose because doebuild makes many changes to the config |
236 |
@@ -1182,8 +1197,7 @@ |
237 |
self.settings = settings |
238 |
self.portroot = settings["PORTDIR"] |
239 |
self.virtual = virtual |
240 |
- self.dbapi = portdbapi( |
241 |
- settings["PORTDIR"], mysettings=settings) |
242 |
+ self.dbapi = portdbapi(mysettings=settings) |
243 |
|
244 |
def dep_bestmatch(self,mydep): |
245 |
"compatibility method" |