From d0f8197481bfaff12e15f899bb538a1024971be4 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 5 Mar 2009 18:32:23 +0000 Subject: [PATCH] Merged from trunk -r12699:12704 | 12700 | In LazyItemsDict, avoid storing empty lists and dicts when | | zmedico | no positional or keyword arguments are given. | | 12701 | Fix headers that contain $Header instead of $Id. | | zmedico | | | 12702 | Fix breakage in USE_EXPAND wildcard handling, from r12697. | | zmedico | | | 12703 | Make USE_EXPAND wildcard expansion more efficient, and | | zmedico | prevent possible duplicates. | | 12704 | If deepcopy() raises a TypeError for a lazy item that has | | zmedico | been added via a call to LazyItemsDict.addLazySingleton(), | | | automatically evaluate the the singleton and instead call | | | deepcopy() on the result. | svn path=/main/branches/prefix/; revision=12761 --- bin/ebuild | 2 +- bin/glsa-check | 6 +++--- bin/misc-functions.sh | 4 ++-- pym/portage/__init__.py | 16 ++++++++++------ pym/portage/_selinux.py | 4 ++-- pym/portage/cache/metadata_overlay.py | 4 ++-- pym/portage/cache/sqlite.py | 4 ++-- pym/portage/cache/volatile.py | 4 ++-- pym/portage/debug.py | 4 ++-- pym/portage/manifest.py | 2 +- pym/portage/update.py | 2 +- pym/portage/util.py | 26 +++++++++++++++++++++++--- 12 files changed, 51 insertions(+), 27 deletions(-) diff --git a/bin/ebuild b/bin/ebuild index 6b24e566b..ca639e475 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -1,7 +1,7 @@ #!@PORTAGE_PYTHON@ -O # Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-src/portage/bin/ebuild,v 1.18.2.3 2005/05/07 04:32:59 ferringb Exp $ +# $Id$ import sys # This block ensures that ^C interrupts are handled quietly. diff --git a/bin/glsa-check b/bin/glsa-check index 2b8e94db9..45f3e95ff 100644 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -1,7 +1,7 @@ #!@PORTAGE_PYTHON@ - -# $Header: $ -# This program is licensed under the GPL, version 2 +# Copyright 2008-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ import os import sys diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 0ad072116..eedb21364 100644 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -1,7 +1,7 @@ #!@PORTAGE_BASH@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header$ +# $Id$ # # Miscellaneous shell functions that make use of the ebuild env but don't need # to be included directly in ebuild.sh. diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index b760d8423..3a039647a 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -2134,7 +2134,9 @@ class config(object): if ebuild_force_test: self.usemask.discard("test") - use.difference_update([x for x in use if x not in iuse_implicit]) + # Allow _* flags from USE_EXPAND wildcards to pass through here. + use.difference_update([x for x in use \ + if x not in iuse_implicit and x[-2:] != '_*']) # Use the calculated USE flags to regenerate the USE_EXPAND flags so # that they are consistent. For optimal performance, use slice @@ -2160,10 +2162,11 @@ class config(object): if has_wildcard: # * means to enable everything in IUSE that's not masked if has_iuse: - for x in iuse_implicit: - if x[:prefix_len] == prefix and x not in self.usemask: - suffix = x[prefix_len:] - var_split.append(suffix) + for suffix in has_iuse: + x = prefix + suffix + if x not in usemask: + if suffix not in expand_flags: + var_split.append(suffix) use.add(x) else: # If there is a wildcard and no matching flags in IUSE then @@ -2206,7 +2209,8 @@ class config(object): # attribute since we still want to be able to see global USE # settings for things like emerge --info. - self.configdict["pkg"]["PORTAGE_USE"] = " ".join(sorted(use)) + self.configdict["pkg"]["PORTAGE_USE"] = \ + " ".join(sorted(x for x in use if x[-2:] != '_*')) def _get_implicit_iuse(self): """ diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py index e4d80fa1e..b5afd9233 100644 --- a/pym/portage/_selinux.py +++ b/pym/portage/_selinux.py @@ -1,6 +1,6 @@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: $ +# $Id$ import selinux from selinux import is_selinux_enabled diff --git a/pym/portage/cache/metadata_overlay.py b/pym/portage/cache/metadata_overlay.py index e25759c4a..a12ffd7ba 100644 --- a/pym/portage/cache/metadata_overlay.py +++ b/pym/portage/cache/metadata_overlay.py @@ -1,6 +1,6 @@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: $ +# $Id$ import time from portage.cache import template diff --git a/pym/portage/cache/sqlite.py b/pym/portage/cache/sqlite.py index a3d313c47..f6e8c103c 100644 --- a/pym/portage/cache/sqlite.py +++ b/pym/portage/cache/sqlite.py @@ -1,6 +1,6 @@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: $ +# $Id$ from portage.cache import fs_template from portage.cache import cache_errors diff --git a/pym/portage/cache/volatile.py b/pym/portage/cache/volatile.py index eb4f1eb9b..108393185 100644 --- a/pym/portage/cache/volatile.py +++ b/pym/portage/cache/volatile.py @@ -1,6 +1,6 @@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: $ +# $Id$ import copy from portage.cache import template diff --git a/pym/portage/debug.py b/pym/portage/debug.py index b9e56ed00..343f8ab6e 100644 --- a/pym/portage/debug.py +++ b/pym/portage/debug.py @@ -1,6 +1,6 @@ -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: $ +# $Id$ import os, sys, threading diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 1244e4232..02836e7ec 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -1,6 +1,6 @@ # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: $ +# $Id$ import errno, os diff --git a/pym/portage/update.py b/pym/portage/update.py index fffdc26eb..70ff68664 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -1,6 +1,6 @@ # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: $ +# $Id$ import errno, os, re, sys diff --git a/pym/portage/util.py b/pym/portage/util.py index 42139c656..d1032f7b9 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -1073,6 +1073,10 @@ class LazyItemsDict(dict): def addLazyItem(self, item_key, value_callable, *pargs, **kwargs): """Add a lazy item for the given key. When the item is requested, value_callable will be called with *pargs and **kwargs arguments.""" + if not pargs: + pargs = None + if not kwargs: + kwargs = None self.lazy_items[item_key] = (value_callable, pargs, kwargs) # make it show up in self.keys(), etc... dict.__setitem__(self, item_key, None) @@ -1095,6 +1099,10 @@ class LazyItemsDict(dict): def __getitem__(self, item_key): if item_key in self.lazy_items: value_callable, pargs, kwargs = self.lazy_items[item_key] + if pargs is None: + pargs = () + if kwargs is None: + kwargs = {} return value_callable(*pargs, **kwargs) else: return dict.__getitem__(self, item_key) @@ -1132,6 +1140,10 @@ class LazyItemsDict(dict): If deepcopy() needs to work, this problem can be avoided by implementing lazy items with normal (non-bound) functions. + + If deepcopy() raises a TypeError for a lazy item that has been added + via a call to addLazySingleton(), the singleton will be automatically + evaluated and deepcopy() will instead be called on the result. """ if memo is None: memo = {} @@ -1141,9 +1153,17 @@ class LazyItemsDict(dict): for k in self: k_copy = deepcopy(k, memo) if k in self.lazy_items: - dict.__setitem__(result, k_copy, None) - result.lazy_items[k_copy] = \ - deepcopy(self.lazy_items[k], memo) + lazy_item = self.lazy_items[k] + try: + result.lazy_items[k_copy] = deepcopy(lazy_item, memo) + except TypeError: + # If deepcopy fails for a lazy singleton, try to + # evaluate the singleton and deepcopy the result. + if not isinstance(lazy_item[0], self._SingletonWrapper): + raise + dict.__setitem__(result, k_copy, deepcopy(self[k], memo)) + else: + dict.__setitem__(result, k_copy, None) else: dict.__setitem__(result, k_copy, deepcopy(self[k], memo)) return result -- 2.26.2