From: Zac Medico Date: Tue, 23 Dec 2008 08:15:00 +0000 (-0000) Subject: Simplify the code from bug #218854. Also, ensure that the set of visible packages X-Git-Tag: v2.2_rc19~28 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=414d1ef2d9137277c2ba4ad3ab49058b73e8805c;p=portage.git Simplify the code from bug #218854. Also, ensure that the set of visible packages thats used by depgraph._iter_atoms_for_pkg() is consistent with the packages that have been selected by depgraph._select_pkg_highest_available(). This should correct potential inconstencies introduced by the package selection changes from bug #252167. svn path=/main/trunk/; revision=12279 --- diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 874e12ac2..a22440c93 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -4307,7 +4307,7 @@ class depgraph(object): # to the graph. self._graph_trees = {} # All Package instances - self._pkg_cache = self._package_cache(self) + self._pkg_cache = {} for myroot in trees: self.trees[myroot] = {} # Create a RootConfig instance that references @@ -5706,6 +5706,12 @@ class depgraph(object): return ret ret = self._select_pkg_highest_available_imp(root, atom, onlydeps=onlydeps) self._highest_pkg_cache[cache_key] = ret + pkg, existing = ret + if pkg is not None: + settings = pkg.root_config.settings + if visible(settings, pkg) and not (pkg.installed and \ + settings._getMissingKeywords(pkg.cpv, pkg.metadata)): + pkg.root_config.visible_pkgs.cpv_inject(pkg) return ret def _select_pkg_highest_available_imp(self, root, atom, onlydeps=False): @@ -6013,22 +6019,6 @@ class depgraph(object): if pkg.cp == cp] break - # If the installed version is in a different slot and it is higher than - # the highest available visible package, _iter_atoms_for_pkg() may fail - # to properly match the available package with a corresponding argument - # atom. Detect this case and correct it here. - if not selective and len(matched_packages) > 1 and \ - matched_packages[-1].installed and \ - matched_packages[-1].slot_atom != \ - matched_packages[-2].slot_atom and \ - matched_packages[-1] > matched_packages[-2]: - pkg = matched_packages[-2] - if pkg.root == self.target_root and \ - self._set_atoms.findAtomForPackage(pkg): - # Select the available package instead - # of the installed package. - matched_packages.pop() - if len(matched_packages) > 1: bestmatch = portage.best( [pkg.cpv for pkg in matched_packages]) @@ -8472,22 +8462,6 @@ class depgraph(object): metadata = self._cpv_pkg_map[cpv].metadata return [metadata.get(x, "") for x in wants] - class _package_cache(dict): - def __init__(self, depgraph): - dict.__init__(self) - self._depgraph = depgraph - - def __setitem__(self, k, v): - dict.__setitem__(self, k, v) - root_config = self._depgraph.roots[v.root] - try: - if visible(root_config.settings, v) and \ - not (v.installed and \ - v.root_config.settings._getMissingKeywords(v.cpv, v.metadata)): - root_config.visible_pkgs.cpv_inject(v) - except portage.exception.InvalidDependString: - pass - class RepoDisplay(object): def __init__(self, roots): self._shown_repos = {}