From d3789b062ba0214c77823345d582875232b27be9 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 10 Sep 2011 14:50:57 -0700 Subject: [PATCH] depgraph: refactor virtual slot --update code This re-implements the change from commit 21330075f07248765016e104b3ba8216903f1ecb in order to avoid executing unnessary virtual slot expansion code when the given atom specifies a slot or --update is enabled. --- pym/_emerge/depgraph.py | 54 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 3cb85dcef..2c3960808 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -6530,32 +6530,34 @@ class _dep_check_composite_db(dbapi): ret = self._match_cache.get(atom) if ret is not None: return ret[:] + + ret = [] pkg, existing = self._depgraph._select_package(self._root, atom) - if not pkg: - ret = [] - else: - # Return the highest available from select_package() as well as - # any matching slots in the graph db. + + if pkg is not None and self._visible(pkg): + self._cpv_pkg_map[pkg.cpv] = pkg + ret.append(pkg.cpv) + + if pkg is not None and \ + atom.slot is None and \ + "--update" not in self._depgraph._frozen_config.myopts and \ + pkg.cp.startswith("virtual/"): + # For new-style virtual lookahead that occurs inside dep_check() + # for bug #141118, examine all slots. This is needed so that newer + # slots will not unnecessarily be pulled in when a satisfying lower + # slot is already installed. For example, if virtual/jdk-1.5 is + # satisfied via gcj-jdk then there's no need to pull in a newer + # slot to satisfy a virtual/jdk dependency, unless --update is + # enabled. slots = set() - slots.add(pkg.metadata["SLOT"]) - if pkg.cp.startswith("virtual/"): - # For new-style virtual lookahead that occurs inside - # dep_check(), examine all slots. This is needed - # so that newer slots will not unnecessarily be pulled in - # when a satisfying lower slot is already installed. For - # example, if virtual/jdk-1.4 is satisfied via kaffe then - # there's no need to pull in a newer slot to satisfy a - # virtual/jdk dependency. - for virt_pkg in self._depgraph._iter_match_pkgs_any( - self._depgraph._frozen_config.roots[self._root], atom): - if virt_pkg.cp != pkg.cp: - continue - slots.add(virt_pkg.slot) - ret = [] - if self._visible(pkg): - self._cpv_pkg_map[pkg.cpv] = pkg - ret.append(pkg.cpv) - slots.remove(pkg.metadata["SLOT"]) + slots.add(pkg.slot) + for virt_pkg in self._depgraph._iter_match_pkgs_any( + self._depgraph._frozen_config.roots[self._root], atom): + if virt_pkg.cp != pkg.cp: + continue + slots.add(virt_pkg.slot) + + slots.remove(pkg.slot) while slots: slot_atom = atom.with_slot(slots.pop()) pkg, existing = self._depgraph._select_package( @@ -6569,10 +6571,6 @@ class _dep_check_composite_db(dbapi): if len(ret) > 1: self._cpv_sort_ascending(ret) - if "--update" in self._depgraph._frozen_config.myopts: - # With --update, we want to force selection of - # the highest available version. - ret = [ret[-1]] self._match_cache[atom] = ret return ret[:] -- 2.26.2