From: Fabian Groffen Date: Thu, 24 Sep 2009 17:26:52 +0000 (-0000) Subject: Merged from trunk -r14388:14396 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=00454100842b2ebbad0a6e90989b8d6616406df7;p=portage.git Merged from trunk -r14388:14396 | 14389 | Fix stack_dicts() to always return a dict. | | zmedico | | | 14390 | Make SlotDict use call self.iteritems() where appropriate | | zmedico | since it implements that method even when running in python | | | 3.x. | | 14391 | Optimize SlotDict.iteritems() a little. | | zmedico | | | 14392 | Optimize vardbapi.getpath(). Thanks to Marat Radchenko | | zmedico | for this patch. | | 14393 | Bug #285979 - Replace references to CDEPEND with UNUSED_00, | | zmedico | to make it clear that this key really is unused. | | 14394 | Fix formatting of size of downloads with Python 3. | | arfrever | | | 14395 | Fix "TypeError: object of type 'filter' has no len()". | | arfrever | | | 14396 | Bug #286118 - Fix dbapi.move_ent() methods so they don't | | zmedico | assume Atom instances can be concatenated with strings | | | (even though they can now, it's not really a good | | | assumption). | svn path=/main/branches/prefix/; revision=14406 --- diff --git a/bin/ebuild.sh b/bin/ebuild.sh index aea4d797b..18c60b27e 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -2074,12 +2074,11 @@ ebuild_main() { fi auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE - DESCRIPTION KEYWORDS INHERITED IUSE CDEPEND PDEPEND PROVIDE EAPI + DESCRIPTION KEYWORDS INHERITED IUSE UNUSED_00 PDEPEND PROVIDE EAPI PROPERTIES DEFINED_PHASES UNUSED_05 UNUSED_04 UNUSED_03 UNUSED_02 UNUSED_01" #the extra $(echo) commands remove newlines - unset CDEPEND [ -n "${EAPI}" ] || EAPI=0 local eapi=$EAPI diff --git a/bin/repoman b/bin/repoman index de78f903b..1ce1556d5 100755 --- a/bin/repoman +++ b/bin/repoman @@ -375,7 +375,6 @@ non_ascii_re = re.compile(r'[^\x00-\x7f]') missingvars=["KEYWORDS","LICENSE","DESCRIPTION","HOMEPAGE","SLOT"] allvars = set(x for x in portage.auxdbkeys if not x.startswith("UNUSED_")) -allvars.discard("CDEPEND") allvars.update(Package.metadata_keys) allvars = sorted(allvars) commitmessage=None @@ -1498,8 +1497,8 @@ for x in scanlist: stats[m+".syntax"] += 1 fails[m+".syntax"].append(catpkg+".ebuild "+m+": "+b) - badlicsyntax = len(filter(lambda x:x=="LICENSE", type_list)) - badprovsyntax = len(filter(lambda x:x=="PROVIDE", type_list)) + badlicsyntax = len([x for x in type_list if x == "LICENSE"]) + badprovsyntax = len([x for x in type_list if x == "PROVIDE"]) baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax badlicsyntax = badlicsyntax > 0 badprovsyntax = badprovsyntax > 0 diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index e37600cf2..a7a8bfba8 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -154,7 +154,6 @@ class Package(Task): _all_metadata_keys = set(x for x in portage.auxdbkeys \ if not x.startswith("UNUSED_")) -_all_metadata_keys.discard("CDEPEND") _all_metadata_keys.update(Package.metadata_keys) _all_metadata_keys = frozenset(_all_metadata_keys) diff --git a/pym/_emerge/format_size.py b/pym/_emerge/format_size.py index ff1aeb23f..b0d39db33 100644 --- a/pym/_emerge/format_size.py +++ b/pym/_emerge/format_size.py @@ -15,7 +15,7 @@ def format_size(mysize): # Always round up to the next kB so that it doesn't show 0 kB when # some small file still needs to be fetched. mysize += 1024 - mysize % 1024 - mystr=str(mysize/1024) + mystr=str(mysize//1024) mycount=len(mystr) while (mycount > 3): mycount-=3 diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index fe1acf30d..4578c42c0 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -8428,7 +8428,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): auxdbkeys=[ 'DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI', 'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', - 'KEYWORDS', 'INHERITED', 'IUSE', 'CDEPEND', + 'KEYWORDS', 'INHERITED', 'IUSE', 'UNUSED_00', 'PDEPEND', 'PROVIDE', 'EAPI', 'PROPERTIES', 'DEFINED_PHASES', 'UNUSED_05', 'UNUSED_04', 'UNUSED_03', 'UNUSED_02', 'UNUSED_01', diff --git a/pym/portage/cache/flat_list.py b/pym/portage/cache/flat_list.py index c7d618c26..bf465efdb 100644 --- a/pym/portage/cache/flat_list.py +++ b/pym/portage/cache/flat_list.py @@ -19,7 +19,7 @@ class database(fs_template.FsBased): # do not screw with this ordering. _eclasses_ needs to be last auxdbkey_order=('DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI', 'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', - 'KEYWORDS', 'IUSE', 'CDEPEND', + 'KEYWORDS', 'IUSE', 'UNUSED_00', 'PDEPEND', 'PROVIDE', 'EAPI', 'PROPERTIES', 'DEFINED_PHASES') def __init__(self, label, auxdbkeys, **config): diff --git a/pym/portage/cache/mappings.py b/pym/portage/cache/mappings.py index a6c111897..bd9f082b9 100644 --- a/pym/portage/cache/mappings.py +++ b/pym/portage/cache/mappings.py @@ -333,12 +333,12 @@ def slot_dict_class(keys, prefix="_val_"): self.update(kwargs) def __iter__(self): - for k, v in self.items(): + for k, v in self.iteritems(): yield k def __len__(self): l = 0 - for i in self.items(): + for i in self.iteritems(): l += 1 return l @@ -346,9 +346,10 @@ def slot_dict_class(keys, prefix="_val_"): return list(self) def iteritems(self): + prefix = self._prefix for k in self.allowed_keys: try: - yield (k, getattr(self, self._prefix + k)) + yield (k, getattr(self, prefix + k)) except AttributeError: pass @@ -356,7 +357,7 @@ def slot_dict_class(keys, prefix="_val_"): return list(self.iteritems()) def itervalues(self): - for k, v in self.items(): + for k, v in self.iteritems(): yield v def values(self): @@ -442,7 +443,7 @@ def slot_dict_class(keys, prefix="_val_"): def popitem(self): try: - k, v = next(iter(self.items())) + k, v = self.iteritems().next() except StopIteration: raise KeyError('container is empty') del self[k] @@ -461,7 +462,7 @@ def slot_dict_class(keys, prefix="_val_"): pass def __str__(self): - return str(dict(self.items())) + return str(dict(self.iteritems())) if sys.hexversion >= 0x3000000: items = iteritems diff --git a/pym/portage/cache/metadata.py b/pym/portage/cache/metadata.py index 3f8ff1149..81b1f17fd 100644 --- a/pym/portage/cache/metadata.py +++ b/pym/portage/cache/metadata.py @@ -26,7 +26,7 @@ class database(flat_hash.database): complete_eclass_entries = False auxdbkey_order=('DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI', 'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', - 'KEYWORDS', 'INHERITED', 'IUSE', 'CDEPEND', + 'KEYWORDS', 'INHERITED', 'IUSE', 'UNUSED_00', 'PDEPEND', 'PROVIDE', 'EAPI', 'PROPERTIES', 'DEFINED_PHASES') autocommits = True diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 0f1de429a..fc0dd730a 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -2,6 +2,8 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +from __future__ import print_function + __all__ = ["bindbapi", "binarytree"] import portage @@ -241,20 +243,19 @@ class binarytree(object): for atom in (origcp, newcp): if not isjustname(atom): raise InvalidPackageName(str(atom)) - origcat = origcp.split("/")[0] - mynewcat = newcp.split("/")[0] + mynewcat = catsplit(newcp)[0] origmatches=self.dbapi.cp_list(origcp) moves = 0 if not origmatches: return moves for mycpv in origmatches: - - mycpsplit = catpkgsplit(mycpv) - mynewcpv = newcp + "-" + mycpsplit[2] - if mycpsplit[3] != "r0": - mynewcpv += "-" + mycpsplit[3] - myoldpkg = mycpv.split("/")[1] - mynewpkg = mynewcpv.split("/")[1] + mycpv_cp = portage.cpv_getkey(mycpv) + if mycpv_cp != origcp: + # Ignore PROVIDE virtual match. + continue + mynewcpv = mycpv.replace(mycpv_cp, str(newcp), 1) + myoldpkg = catsplit(mycpv)[1] + mynewpkg = catsplit(mynewcpv)[1] if (mynewpkg != myoldpkg) and os.path.exists(self.getname(mynewcpv)): writemsg(_("!!! Cannot update binary: Destination exists.\n"), diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 24e93dc20..3bf002a78 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -51,6 +51,7 @@ from portage.cache.mappings import slot_dict_class import codecs import re, shutil, stat, errno, copy, subprocess import logging +import os as _os import sys import warnings @@ -1555,9 +1556,13 @@ class vardbapi(dbapi): self._owners = self._owners_db(self) def getpath(self, mykey, filename=None): - rValue = os.path.join(self.root, VDB_PATH, mykey) - if filename != None: - rValue = os.path.join(rValue, filename) + # This is an optimized hotspot, so don't use unicode-wrapped + # os module and don't use os.path.join(). + rValue = self.root + _os.sep + VDB_PATH + _os.sep + mykey + if filename is not None: + # If filename is always relative, we can do just + # rValue += _os.sep + filename + rValue = _os.path.join(rValue, filename) return rValue def cpv_exists(self, mykey): @@ -1603,12 +1608,12 @@ class vardbapi(dbapi): if not origmatches: return moves for mycpv in origmatches: - mycpsplit = catpkgsplit(mycpv) - mynewcpv = newcp + "-" + mycpsplit[2] - mynewcat = newcp.split("/")[0] - if mycpsplit[3] != "r0": - mynewcpv += "-" + mycpsplit[3] - mycpsplit_new = catpkgsplit(mynewcpv) + mycpv_cp = cpv_getkey(mycpv) + if mycpv_cp != origcp: + # Ignore PROVIDE virtual match. + continue + mynewcpv = mycpv.replace(mycpv_cp, str(newcp), 1) + mynewcat = catsplit(newcp)[0] origpath = self.getpath(mycpv) if not os.path.exists(origpath): continue diff --git a/pym/portage/util.py b/pym/portage/util.py index bae33a05f..a3d33fc31 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -217,12 +217,10 @@ def stack_dicts(dicts, incremental=0, incrementals=[], ignore_none=0): """Stacks an array of dict-types into one array. Optionally merging or overwriting matching key/value pairs for the dict[key]->string. Returns a single dict.""" - final_dict = None + final_dict = {} for mydict in dicts: if not mydict: continue - if final_dict is None: - final_dict = {} for k, v in mydict.items(): if k in final_dict and (incremental or (k in incrementals)): final_dict[k] += " " + v