Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10760 - in main/branches/prefix: . bin man pym/_emerge pym/portage pym/portage/dbapi pym/portage/sets pym/portage/tests/sets/shell
Date: Sun, 22 Jun 2008 15:29:45
Message-Id: E1KARVa-0003Dt-HV@stork.gentoo.org
1 Author: grobian
2 Date: 2008-06-22 15:29:37 +0000 (Sun, 22 Jun 2008)
3 New Revision: 10760
4
5 Modified:
6 main/branches/prefix/NEWS
7 main/branches/prefix/bin/check-implicit-pointer-usage.py
8 main/branches/prefix/bin/repoman
9 main/branches/prefix/man/repoman.1
10 main/branches/prefix/pym/_emerge/__init__.py
11 main/branches/prefix/pym/portage/__init__.py
12 main/branches/prefix/pym/portage/dbapi/porttree.py
13 main/branches/prefix/pym/portage/dep.py
14 main/branches/prefix/pym/portage/sets/files.py
15 main/branches/prefix/pym/portage/sets/libs.py
16 main/branches/prefix/pym/portage/tests/sets/shell/testShell.py
17 Log:
18 Merged from trunk 10738:10759
19
20 | 10739 | Make the visibility related config methods such as |
21 | zmedico | getMaskAtom() and getProfileMaskAtom() private since these |
22 | | methods really should take Package instances before we |
23 | | expose them as public api. |
24
25 | 10740 | Instead of having Atom inherit from str, just emulate the |
26 | zmedico | interface. This allows us to define __slots__ (not allowed |
27 | | when inheriting from str) and therefore should conserve |
28 | | some memory by avoiding a __dict__ attribute on every Atom. |
29
30 | 10741 | Use a metaclass to cache Atom instances transparently. This |
31 | zmedico | should improve performance and conserve memory in cases |
32 | | when the same atom is more than once. |
33
34 | 10742 | Make the Atom cache dict private and add a docstring for |
35 | zmedico | _AtomCache. |
36
37 | 10743 | Make Atom use str.__hash__. |
38 | zmedico | |
39
40 | 10744 | Make Atom use str.__eq__ and __ne__ also. |
41 | zmedico | |
42
43 | 10745 | Make isvalidatom() use the Atom cache to avoid validating |
44 | zmedico | the same atom twice. |
45
46 | 10746 | Bug #228595 - Use os.path.realpath() before comparing paths |
47 | zmedico | to those returned from portdbapi.getRepositoryPath() since |
48 | | those paths are also cannonical. |
49
50 | 10747 | Add subversion support for repoman. (thanks grobian) |
51 | zmedico | |
52
53 | 10748 | Remove unused Atom.string attribute. |
54 | zmedico | |
55
56 | 10749 | Fix Atom -> str breakage in WorldSet.write(). |
57 | zmedico | |
58
59 | 10750 | drop old -i,--include-masked option #226429 by Tobias |
60 | SpankMan | Klausmann |
61
62 | 10751 | Use bash's built-in echo instead of the actual echo binary |
63 | zmedico | since it has compatibility issues on FreeBSD systems. |
64 | | Thanks to aballier for reporting the issue and testing this |
65 | | patch. |
66
67 | 10752 | Exclude calls to autoheader and makeinfo from the automake |
68 | zmedico | "maintainer mode" check (filter some false positives). |
69 | | Thanks to Flameeyes. |
70
71 | 10753 | Fix implicit_pattern to match different quote character |
72 | zmedico | found in warnings generated by gcc-4.3. Thanks to aballier |
73 | | for reporting with sample log. |
74
75 | 10754 | Make LibraryConsumerSet.mapPathsToAtoms() use the contents |
76 | zmedico | index for more efficient owner lookups. |
77
78 | 10755 | Fix Atom -> str breakage in depgraph.display_problems(). |
79 | zmedico | |
80
81 | 10756 | Bug #228489 - Restore the "ci" alias for "commit" mode. |
82 | zmedico | Thanks to grobian for the patch. |
83
84 | 10757 | Implement Atom.__cmp__() so that things like list.sort() |
85 | zmedico | work correctly for Atom instances. |
86
87 | 10758 | Fix Atom -> str breakage in |
88 | zmedico | depgraph._show_slot_collision_notice(). Thanks to Arfrever |
89 | | for reporting. |
90
91 | 10759 | Fix broken path handling wrt $ROOT in |
92 | zmedico | LibraryConsumerSet.mapPathsToAtoms(). |
93
94
95 Modified: main/branches/prefix/NEWS
96 ===================================================================
97 --- main/branches/prefix/NEWS 2008-06-22 04:04:50 UTC (rev 10759)
98 +++ main/branches/prefix/NEWS 2008-06-22 15:29:37 UTC (rev 10760)
99 @@ -3,6 +3,7 @@
100 portage-2.2
101 -------------
102
103 +* Add subversion support for repoman.
104 * It is now possible to use `emerge <file>` to reinstall the package that
105 installed a particular file. Package contents entries are indexed to
106 improve performance. A command such as `emerge /lib/modules` can serve
107
108 Modified: main/branches/prefix/bin/check-implicit-pointer-usage.py
109 ===================================================================
110 --- main/branches/prefix/bin/check-implicit-pointer-usage.py 2008-06-22 04:04:50 UTC (rev 10759)
111 +++ main/branches/prefix/bin/check-implicit-pointer-usage.py 2008-06-22 15:29:37 UTC (rev 10760)
112 @@ -17,7 +17,7 @@
113 import sys
114
115 implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration "
116 - + "of function `([^']*)'")
117 + + "of function [`']([^']*)'")
118 pointer_pattern = re.compile(
119 "([^:]*):(\d+): warning: "
120 + "("
121
122 Modified: main/branches/prefix/bin/repoman
123 ===================================================================
124 --- main/branches/prefix/bin/repoman 2008-06-22 04:04:50 UTC (rev 10759)
125 +++ main/branches/prefix/bin/repoman 2008-06-22 15:29:37 UTC (rev 10760)
126 @@ -145,6 +145,7 @@
127
128 modes = {
129 'commit' : 'Run a scan then commit changes',
130 + 'ci' : 'Run a scan then commit changes',
131 'fix' : 'Fix simple QA issues (stray digests, missing digests)',
132 'full' : 'Scan directory tree and print all issues (not a summary)',
133 'help' : 'Show this screen',
134 @@ -223,6 +224,9 @@
135
136 if not opts.mode:
137 opts.mode = 'full' #default to full
138 +
139 + if opts.mode == 'ci':
140 + opts.mode = 'commit' # backwards compat shortcut
141
142 if opts.mode == 'commit' and not (opts.force or opts.pretend):
143 if opts.ignore_masked:
144
145 Modified: main/branches/prefix/man/repoman.1
146 ===================================================================
147 --- main/branches/prefix/man/repoman.1 2008-06-22 04:04:50 UTC (rev 10759)
148 +++ main/branches/prefix/man/repoman.1 2008-06-22 15:29:37 UTC (rev 10760)
149 @@ -25,9 +25,6 @@
150 \fB-p\fR, \fB--pretend\fR
151 Don't commit or fix anything; just show what would be done
152 .TP
153 -\fB-i\fR, \fB--include-masked\fR
154 -Include masked packages in scans at category or tree level
155 -.TP
156 \fB-x\fR, \fB--xmlparse\fR
157 Forces the metadata.xml parse check to be carried out
158 .TP
159
160 Modified: main/branches/prefix/pym/_emerge/__init__.py
161 ===================================================================
162 --- main/branches/prefix/pym/_emerge/__init__.py 2008-06-22 04:04:50 UTC (rev 10759)
163 +++ main/branches/prefix/pym/_emerge/__init__.py 2008-06-22 15:29:37 UTC (rev 10760)
164 @@ -1141,14 +1141,14 @@
165 if not portage.eapi_is_supported(pkg.metadata["EAPI"]):
166 return False
167 if not pkg.installed and \
168 - pkgsettings.getMissingKeywords(pkg.cpv, pkg.metadata):
169 + pkgsettings._getMissingKeywords(pkg.cpv, pkg.metadata):
170 return False
171 - if pkgsettings.getMaskAtom(pkg.cpv, pkg.metadata):
172 + if pkgsettings._getMaskAtom(pkg.cpv, pkg.metadata):
173 return False
174 - if pkgsettings.getProfileMaskAtom(pkg.cpv, pkg.metadata):
175 + if pkgsettings._getProfileMaskAtom(pkg.cpv, pkg.metadata):
176 return False
177 try:
178 - if pkgsettings.getMissingLicenses(pkg.cpv, pkg.metadata):
179 + if pkgsettings._getMissingLicenses(pkg.cpv, pkg.metadata):
180 return False
181 except portage.exception.InvalidDependString:
182 return False
183 @@ -1221,7 +1221,7 @@
184 have_eapi_mask = True
185 try:
186 missing_licenses = \
187 - pkgsettings.getMissingLicenses(
188 + pkgsettings._getMissingLicenses(
189 cpv, metadata)
190 except portage.exception.InvalidDependString:
191 # This will have already been reported
192 @@ -2076,7 +2076,7 @@
193 # Max number of parents shown, to avoid flooding the display.
194 max_parents = 3
195 for slot_atom, root in self._slot_collision_info:
196 - msg.append(slot_atom)
197 + msg.append(str(slot_atom))
198 msg.append("\n\n")
199 slot_nodes = []
200 for node in self._slot_collision_nodes:
201 @@ -3227,7 +3227,7 @@
202 # reinstall the same exact version only due
203 # to a KEYWORDS mask.
204 if installed and matched_packages and \
205 - pkgsettings.getMissingKeywords(
206 + pkgsettings._getMissingKeywords(
207 pkg.cpv, pkg.metadata):
208 different_version = None
209 for avail_pkg in matched_packages:
210 @@ -3576,7 +3576,7 @@
211 if pkg_in_graph and not visible(pkgsettings, pkg):
212 self._masked_installed.add(pkg)
213 elif graph_complete_for_root and \
214 - pkgsettings.getMissingKeywords(
215 + pkgsettings._getMissingKeywords(
216 pkg.cpv, pkg.metadata) and \
217 pkg.metadata["KEYWORDS"].split() and \
218 not pkg_in_graph:
219 @@ -5212,7 +5212,7 @@
220 " Ebuilds for the following packages are either all\n")
221 sys.stderr.write(colorize("BAD", "!!!") + \
222 " masked or don't exist:\n")
223 - sys.stderr.write(" ".join(atom for arg, atom in \
224 + sys.stderr.write(" ".join(str(atom) for arg, atom in \
225 self._missing_args) + "\n")
226
227 if self._pprovided_args:
228 @@ -5710,7 +5710,7 @@
229 try:
230 if visible(root_config.settings, v) and \
231 not (v.installed and \
232 - v.root_config.settings.getMissingKeywords(v.cpv, v.metadata)):
233 + v.root_config.settings._getMissingKeywords(v.cpv, v.metadata)):
234 root_config.visible_pkgs.cpv_inject(v)
235 except portage.exception.InvalidDependString:
236 pass
237 @@ -9166,6 +9166,7 @@
238 if "porttree" in trees[root]:
239 db = trees[root]["porttree"].dbapi
240 paths = (db.mysettings["PORTDIR"]+" "+db.mysettings["PORTDIR_OVERLAY"]).split()
241 + paths = [os.path.realpath(p) for p in paths]
242 repos = db.getRepositories()
243 for r in repos:
244 p = db.getRepositoryPath(r)
245
246 Modified: main/branches/prefix/pym/portage/__init__.py
247 ===================================================================
248 --- main/branches/prefix/pym/portage/__init__.py 2008-06-22 04:04:50 UTC (rev 10759)
249 +++ main/branches/prefix/pym/portage/__init__.py 2008-06-22 15:29:37 UTC (rev 10760)
250 @@ -2211,7 +2211,7 @@
251
252 return iuse_implicit
253
254 - def getMaskAtom(self, cpv, metadata):
255 + def _getMaskAtom(self, cpv, metadata):
256 """
257 Take a package and return a matching package.mask atom, or None if no
258 such atom exists or it has been cancelled by package.unmask. PROVIDE
259 @@ -2240,7 +2240,7 @@
260 return x
261 return None
262
263 - def getProfileMaskAtom(self, cpv, metadata):
264 + def _getProfileMaskAtom(self, cpv, metadata):
265 """
266 Take a package and return a matching profile atom, or None if no
267 such atom exists. Note that a profile atom may or may not have a "*"
268 @@ -2265,7 +2265,7 @@
269 return x
270 return None
271
272 - def getMissingKeywords(self, cpv, metadata):
273 + def _getMissingKeywords(self, cpv, metadata):
274 """
275 Take a package and return a list of any KEYWORDS that the user may
276 may need to accept for the given package. If the KEYWORDS are empty
277 @@ -2342,7 +2342,7 @@
278 missing = mygroups
279 return missing
280
281 - def getMissingLicenses(self, cpv, metadata):
282 + def _getMissingLicenses(self, cpv, metadata):
283 """
284 Take a LICENSE string and return a list any licenses that the user may
285 may need to accept for the given package. The returned list will not
286 @@ -2369,9 +2369,9 @@
287 license_struct = portage.dep.use_reduce(
288 license_struct, uselist=metadata["USE"].split())
289 license_struct = portage.dep.dep_opconvert(license_struct)
290 - return self._getMissingLicenses(license_struct, acceptable_licenses)
291 + return self._getMaskedLicenses(license_struct, acceptable_licenses)
292
293 - def _getMissingLicenses(self, license_struct, acceptable_licenses):
294 + def _getMaskedLicenses(self, license_struct, acceptable_licenses):
295 if not license_struct:
296 return []
297 if license_struct[0] == "||":
298 @@ -2379,7 +2379,7 @@
299 for element in license_struct[1:]:
300 if isinstance(element, list):
301 if element:
302 - ret.append(self._getMissingLicenses(
303 + ret.append(self._getMaskedLicenses(
304 element, acceptable_licenses))
305 if not ret[-1]:
306 return []
307 @@ -2395,7 +2395,7 @@
308 for element in license_struct:
309 if isinstance(element, list):
310 if element:
311 - ret.extend(self._getMissingLicenses(element,
312 + ret.extend(self._getMaskedLicenses(element,
313 acceptable_licenses))
314 else:
315 if element not in acceptable_licenses:
316 @@ -4217,9 +4217,12 @@
317 configure_opts_warn_re = re.compile(
318 r'^configure: WARNING: Unrecognized options: .*')
319 am_maintainer_mode_re = re.compile(r'.*/missing --run .*')
320 + am_maintainer_mode_exclude_re = \
321 + re.compile(r'.*/missing --run (autoheader|makeinfo)')
322 try:
323 for line in f:
324 - if am_maintainer_mode_re.search(line) is not None:
325 + if am_maintainer_mode_re.search(line) is not None and \
326 + am_maintainer_mode_exclude_re.search(line) is None:
327 am_maintainer_mode.append(line.rstrip("\n"))
328 if configure_opts_warn_re.match(line) is not None:
329 configure_opts_warn.append(line.rstrip("\n"))
330 @@ -6398,11 +6401,11 @@
331 rValue = []
332
333 # profile checking
334 - if settings.getProfileMaskAtom(mycpv, metadata):
335 + if settings._getProfileMaskAtom(mycpv, metadata):
336 rValue.append("profile")
337
338 # package.mask checking
339 - if settings.getMaskAtom(mycpv, metadata):
340 + if settings._getMaskAtom(mycpv, metadata):
341 rValue.append("package.mask")
342
343 # keywords checking
344 @@ -6467,7 +6470,7 @@
345 break
346
347 try:
348 - missing_licenses = settings.getMissingLicenses(mycpv, metadata)
349 + missing_licenses = settings._getMissingLicenses(mycpv, metadata)
350 if missing_licenses:
351 allowed_tokens = set(["||", "(", ")"])
352 allowed_tokens.update(missing_licenses)
353
354 Modified: main/branches/prefix/pym/portage/dbapi/porttree.py
355 ===================================================================
356 --- main/branches/prefix/pym/portage/dbapi/porttree.py 2008-06-22 04:04:50 UTC (rev 10759)
357 +++ main/branches/prefix/pym/portage/dbapi/porttree.py 2008-06-22 15:29:37 UTC (rev 10760)
358 @@ -654,11 +654,11 @@
359 continue
360 if mydep.slot and mydep.slot != metadata["SLOT"]:
361 continue
362 - if settings.getMissingKeywords(cpv, metadata):
363 + if settings._getMissingKeywords(cpv, metadata):
364 continue
365 - if settings.getMaskAtom(cpv, metadata):
366 + if settings._getMaskAtom(cpv, metadata):
367 continue
368 - if settings.getProfileMaskAtom(cpv, metadata):
369 + if settings._getProfileMaskAtom(cpv, metadata):
370 continue
371 if local_config:
372 metadata["USE"] = ""
373 @@ -666,7 +666,7 @@
374 self.doebuild_settings.setcpv(cpv, mydb=metadata)
375 metadata["USE"] = self.doebuild_settings.get("USE", "")
376 try:
377 - if settings.getMissingLicenses(cpv, metadata):
378 + if settings._getMissingLicenses(cpv, metadata):
379 continue
380 except InvalidDependString:
381 continue
382 @@ -721,8 +721,8 @@
383
384 db_keys = ["SLOT"]
385 visible = []
386 - getMaskAtom = self.mysettings.getMaskAtom
387 - getProfileMaskAtom = self.mysettings.getProfileMaskAtom
388 + getMaskAtom = self.mysettings._getMaskAtom
389 + getProfileMaskAtom = self.mysettings._getProfileMaskAtom
390 for cpv in mylist:
391 try:
392 metadata = dict(izip(db_keys, self.aux_get(cpv, db_keys)))
393 @@ -761,7 +761,7 @@
394 continue
395 if not eapi_is_supported(metadata["EAPI"]):
396 continue
397 - if self.mysettings.getMissingKeywords(mycpv, metadata):
398 + if self.mysettings._getMissingKeywords(mycpv, metadata):
399 continue
400 if local_config:
401 metadata["USE"] = ""
402 @@ -769,7 +769,7 @@
403 self.doebuild_settings.setcpv(mycpv, mydb=metadata)
404 metadata["USE"] = self.doebuild_settings.get("USE", "")
405 try:
406 - if self.mysettings.getMissingLicenses(mycpv, metadata):
407 + if self.mysettings._getMissingLicenses(mycpv, metadata):
408 continue
409 except InvalidDependString:
410 continue
411
412 Modified: main/branches/prefix/pym/portage/dep.py
413 ===================================================================
414 --- main/branches/prefix/pym/portage/dep.py 2008-06-22 04:04:50 UTC (rev 10759)
415 +++ main/branches/prefix/pym/portage/dep.py 2008-06-22 15:29:37 UTC (rev 10760)
416 @@ -392,12 +392,40 @@
417 tokens.extend(self.conditional_disabled.difference(use))
418 return _use_dep(tokens)
419
420 -class Atom(str):
421 +class _AtomCache(type):
422 + """
423 + Cache Atom instances from constructor calls and reuse
424 + identical instances when available.
425 + """
426 + def __call__(cls, s):
427 + instance = cls._atoms.get(s)
428 + if instance is None:
429 + instance = super(_AtomCache, cls).__call__(s)
430 + cls._atoms[s] = instance
431 + return instance
432
433 +class Atom(object):
434 +
435 + """
436 + For compatibility with existing atom string manipulation code, this
437 + class emulates most of the str methods that are useful with atoms.
438 + """
439 +
440 + __metaclass__ = _AtomCache
441 + _atoms = {}
442 +
443 + _str_methods = ("endswith", "find", "index", "lstrip", "replace",
444 + "startswith", "strip", "rindex", "rfind", "rstrip", "__getitem__",
445 + "__eq__", "__hash__", "__len__", "__ne__", "__repr__", "__str__")
446 +
447 + __slots__ = ("__weakref__", "blocker", "cp", "cpv", "operator",
448 + "slot", "use") + _str_methods
449 +
450 def __init__(self, s):
451 - str.__init__(self, s)
452 if not isvalidatom(s, allow_blockers=True):
453 raise InvalidAtom(s)
454 + for x in self._str_methods:
455 + setattr(self, x, getattr(s, x))
456 self.blocker = "!" == s[:1]
457 if self.blocker:
458 s = s[1:]
459 @@ -412,6 +440,15 @@
460 else:
461 self.use = None
462
463 + def __cmp__(self, other):
464 + self_str = str(self)
465 + other_str = str(other)
466 + if self_str == other_str:
467 + return 0
468 + if self_str > other_str:
469 + return 1
470 + return -1
471 +
472 def get_operator(mydep):
473 """
474 Return the operator used in a depstring.
475 @@ -583,6 +620,9 @@
476 1) 0 if the atom is invalid
477 2) 1 if the atom is valid
478 """
479 + existing_atom = Atom._atoms.get(atom)
480 + if existing_atom is not None:
481 + atom = existing_atom
482 if isinstance(atom, Atom):
483 if atom.blocker and not allow_blockers:
484 return 0
485
486 Modified: main/branches/prefix/pym/portage/sets/files.py
487 ===================================================================
488 --- main/branches/prefix/pym/portage/sets/files.py 2008-06-22 04:04:50 UTC (rev 10759)
489 +++ main/branches/prefix/pym/portage/sets/files.py 2008-06-22 15:29:37 UTC (rev 10760)
490 @@ -184,7 +184,8 @@
491 return setname.startswith(SETPREFIX)
492
493 def write(self):
494 - write_atomic(self._filename, "\n".join(sorted(self._atoms))+"\n")
495 + write_atomic(self._filename,
496 + "".join(sorted("%s\n" % x for x in self._atoms)))
497 write_atomic(self._filename2, "\n".join(sorted(self._nonatoms))+"\n")
498
499 def load(self):
500
501 Modified: main/branches/prefix/pym/portage/sets/libs.py
502 ===================================================================
503 --- main/branches/prefix/pym/portage/sets/libs.py 2008-06-22 04:04:50 UTC (rev 10759)
504 +++ main/branches/prefix/pym/portage/sets/libs.py 2008-06-22 15:29:37 UTC (rev 10760)
505 @@ -4,11 +4,8 @@
506
507 from portage.sets.base import PackageSet
508 from portage.sets import get_boolean
509 -from portage.dbapi.vartree import dblink
510 -from portage.versions import catsplit, catpkgsplit
511 +from portage.versions import catpkgsplit
512
513 -import os
514 -
515 class LibraryConsumerSet(PackageSet):
516 _operations = ["merge", "unmerge"]
517
518 @@ -19,17 +16,11 @@
519
520 def mapPathsToAtoms(self, paths):
521 rValue = set()
522 - for cpv in self.dbapi.cpv_all():
523 - mysplit = catsplit(cpv)
524 - link = dblink(mysplit[0], mysplit[1], myroot=self.dbapi.root, \
525 - mysettings=self.dbapi.settings, treetype='vartree', \
526 - vartree=self.dbapi.vartree)
527 - if paths.intersection(link.getcontents()):
528 - cat, pn = catpkgsplit(cpv)[:2]
529 - slot = self.dbapi.aux_get(cpv, ["SLOT"])[0]
530 - rValue.add("%s/%s:%s" % (cat, pn, slot))
531 + for link, p in self.dbapi._owners.iter_owners(paths):
532 + cat, pn = catpkgsplit(link.mycpv)[:2]
533 + slot = self.dbapi.aux_get(link.mycpv, ["SLOT"])[0]
534 + rValue.add("%s/%s:%s" % (cat, pn, slot))
535 return rValue
536 -
537
538 class PreservedLibraryConsumerSet(LibraryConsumerSet):
539 def load(self):
540
541 Modified: main/branches/prefix/pym/portage/tests/sets/shell/testShell.py
542 ===================================================================
543 --- main/branches/prefix/pym/portage/tests/sets/shell/testShell.py 2008-06-22 04:04:50 UTC (rev 10759)
544 +++ main/branches/prefix/pym/portage/tests/sets/shell/testShell.py 2008-06-22 15:29:37 UTC (rev 10760)
545 @@ -19,10 +19,11 @@
546 def testCommand(self):
547
548 input = set(test_cps)
549 - command = find_binary("echo")
550 - command += " -e "
551 + command = find_binary("bash")
552 + command += " -c '"
553 for a in input:
554 - command += "\"%s\n\"" % a
555 + command += " echo -e \"%s\" ; " % a
556 + command += "'"
557 s = CommandOutputSet(command)
558 atoms = s.getAtoms()
559 self.assertEqual(atoms, input)
560
561 --
562 gentoo-commits@l.g.o mailing list