From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SLUAY-0003cu-7R for garchives@archives.gentoo.org; Sat, 21 Apr 2012 06:51:42 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 55531E064B; Sat, 21 Apr 2012 06:51:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 0CF22E064B for ; Sat, 21 Apr 2012 06:51:29 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4505F1B4059 for ; Sat, 21 Apr 2012 06:51:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id D504EE5403 for ; Sat, 21 Apr 2012 06:51:27 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1334990731.d603f1440c814377fbc1965729fd9b6b008cf76d.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/PackageVirtualDbapi.py pym/_emerge/depgraph.py pym/portage/dbapi/porttree.py pym/portage/dbapi/vartree.py pym/portage/dbapi/virtual.py X-VCS-Directories: pym/portage/dbapi/ pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: d603f1440c814377fbc1965729fd9b6b008cf76d X-VCS-Branch: master Date: Sat, 21 Apr 2012 06:51:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 6ca63726-2119-4959-8d7f-0548d2ebe15d X-Archives-Hash: 9be5ef539dfb4c0ea0b4d13a222a073e commit: d603f1440c814377fbc1965729fd9b6b008cf76d Author: Zac Medico gentoo org> AuthorDate: Sat Apr 21 06:38:17 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Apr 21 06:45:31 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Dd603f144 dbapi: account for unevaluated_atom in caches This will fix bug 412391. This is analogous to the bug fixed in commit 5438bb29c996d777b6343515995176912a7c137f. --- pym/_emerge/PackageVirtualDbapi.py | 16 ++++++++++------ pym/_emerge/depgraph.py | 5 +++-- pym/portage/dbapi/porttree.py | 26 +++++++++++++------------- pym/portage/dbapi/vartree.py | 5 +++-- pym/portage/dbapi/virtual.py | 16 ++++++++++------ 5 files changed, 39 insertions(+), 29 deletions(-) diff --git a/pym/_emerge/PackageVirtualDbapi.py b/pym/_emerge/PackageVirt= ualDbapi.py index a692bb6..a34d21c 100644 --- a/pym/_emerge/PackageVirtualDbapi.py +++ b/pym/_emerge/PackageVirtualDbapi.py @@ -1,8 +1,9 @@ -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 import sys from portage.dbapi import dbapi +from portage.dbapi.dep_expand import dep_expand =20 class PackageVirtualDbapi(dbapi): """ @@ -76,18 +77,21 @@ class PackageVirtualDbapi(dbapi): self._match_cache =3D {} =20 def match(self, origdep, use_cache=3D1): - result =3D self._match_cache.get(origdep) + atom =3D dep_expand(origdep, mydb=3Dself, settings=3Dself.settings) + cache_key =3D (atom, atom.unevaluated_atom) + result =3D self._match_cache.get(cache_key) if result is not None: return result[:] - result =3D dbapi.match(self, origdep, use_cache=3Duse_cache) - self._match_cache[origdep] =3D result + result =3D list(self._iter_match(atom, self.cp_list(atom.cp))) + self._match_cache[cache_key] =3D result return result[:] =20 def cpv_exists(self, cpv, myrepo=3DNone): return cpv in self._cpv_map =20 def cp_list(self, mycp, use_cache=3D1): - cachelist =3D self._match_cache.get(mycp) + cache_key =3D (mycp, mycp) + cachelist =3D self._match_cache.get(cache_key) # cp_list() doesn't expand old-style virtuals if cachelist and cachelist[0].startswith(mycp): return cachelist[:] @@ -98,7 +102,7 @@ class PackageVirtualDbapi(dbapi): cpv_list =3D [pkg.cpv for pkg in cpv_list] self._cpv_sort_ascending(cpv_list) if not (not cpv_list and mycp.startswith("virtual/")): - self._match_cache[mycp] =3D cpv_list + self._match_cache[cache_key] =3D cpv_list return cpv_list[:] =20 def cp_all(self): diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index e77c0e8..e624559 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -6753,7 +6753,8 @@ class _dep_check_composite_db(dbapi): return ret =20 def match(self, atom): - ret =3D self._match_cache.get(atom) + cache_key =3D (atom, atom.unevaluated_atom) + ret =3D self._match_cache.get(cache_key) if ret is not None: return ret[:] =20 @@ -6801,7 +6802,7 @@ class _dep_check_composite_db(dbapi): if len(ret) > 1: self._cpv_sort_ascending(ret) =20 - self._match_cache[atom] =3D ret + self._match_cache[cache_key] =3D ret return ret[:] =20 def _visible(self, pkg): diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.p= y index 382bcda..f9d78dc 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -1,4 +1,4 @@ -# Copyright 1998-2011 Gentoo Foundation +# Copyright 1998-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 __all__ =3D [ @@ -731,7 +731,7 @@ class portdbapi(dbapi): # profile (due to old-style virtuals). Do not propagate # old-style virtuals since cp_list() doesn't expand them. if not (not cachelist and mycp.startswith("virtual/")): - self.xcache["match-all"][mycp] =3D cachelist + self.xcache["match-all"][(mycp, mycp)] =3D cachelist return cachelist[:] mysplit =3D mycp.split("/") invalid_category =3D mysplit[0] not in self._categories @@ -786,7 +786,7 @@ class portdbapi(dbapi): # Do not propagate old-style virtuals since # cp_list() doesn't expand them. if not (not cachelist and mycp.startswith("virtual/")): - self.xcache["match-all"][mycp] =3D cachelist + self.xcache["match-all"][(mycp, mycp)] =3D cachelist return mylist =20 def freeze(self): @@ -809,19 +809,21 @@ class portdbapi(dbapi): "has been renamed to match-visible", DeprecationWarning, stacklevel=3D2) =20 - #if no updates are being made to the tree, we can consult our xcache..= . - if self.frozen: - try: - return self.xcache[level][origdep][:] - except KeyError: - pass - if mydep is None: #this stuff only runs on first call of xmatch() #create mydep, mykey from origdep mydep =3D dep_expand(origdep, mydb=3Dself, settings=3Dself.settings) mykey =3D mydep.cp =20 + #if no updates are being made to the tree, we can consult our xcache..= . + cache_key =3D None + if self.frozen: + cache_key =3D (mydep, mydep.unevaluated_atom) + try: + return self.xcache[level][cache_key][:] + except KeyError: + pass + myval =3D None mytree =3D None if mydep.repo is not None: @@ -930,9 +932,7 @@ class portdbapi(dbapi): if self.frozen: xcache_this_level =3D self.xcache.get(level) if xcache_this_level is not None: - xcache_this_level[mydep] =3D myval - if origdep and origdep !=3D mydep: - xcache_this_level[origdep] =3D myval + xcache_this_level[cache_key] =3D myval myval =3D myval[:] =20 return myval diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index a3a6c76..ec9f87c 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -484,6 +484,7 @@ class vardbapi(dbapi): "caching match function" mydep =3D dep_expand( origdep, mydb=3Dself, use_cache=3Duse_cache, settings=3Dself.settings= ) + cache_key =3D (mydep, mydep.unevaluated_atom) mykey =3D dep_getkey(mydep) mycat =3D catsplit(mykey)[0] if not use_cache: @@ -505,8 +506,8 @@ class vardbapi(dbapi): if mydep not in self.matchcache[mycat]: mymatch =3D list(self._iter_match(mydep, self.cp_list(mydep.cp, use_cache=3Duse_cache))) - self.matchcache[mycat][mydep] =3D mymatch - return self.matchcache[mycat][mydep][:] + self.matchcache[mycat][cache_key] =3D mymatch + return self.matchcache[mycat][cache_key][:] =20 def findname(self, mycpv, myrepo=3DNone): return self.getpath(str(mycpv), filename=3Dcatsplit(mycpv)[1]+".ebuild= ") diff --git a/pym/portage/dbapi/virtual.py b/pym/portage/dbapi/virtual.py index ec97ffe..eed1407 100644 --- a/pym/portage/dbapi/virtual.py +++ b/pym/portage/dbapi/virtual.py @@ -1,8 +1,9 @@ -# Copyright 1998-2007 Gentoo Foundation +# Copyright 1998-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 =20 from portage.dbapi import dbapi +from portage.dbapi.dep_expand import dep_expand from portage import cpv_getkey =20 class fakedbapi(dbapi): @@ -31,18 +32,21 @@ class fakedbapi(dbapi): self._match_cache =3D {} =20 def match(self, origdep, use_cache=3D1): - result =3D self._match_cache.get(origdep, None) + atom =3D dep_expand(origdep, mydb=3Dself, settings=3Dself.settings) + cache_key =3D (atom, atom.unevaluated_atom) + result =3D self._match_cache.get(cache_key) if result is not None: return result[:] - result =3D dbapi.match(self, origdep, use_cache=3Duse_cache) - self._match_cache[origdep] =3D result + result =3D list(self._iter_match(atom, self.cp_list(atom.cp))) + self._match_cache[cache_key] =3D result return result[:] =20 def cpv_exists(self, mycpv, myrepo=3DNone): return mycpv in self.cpvdict =20 def cp_list(self, mycp, use_cache=3D1, myrepo=3DNone): - cachelist =3D self._match_cache.get(mycp) + cache_key =3D (mycp, mycp) + cachelist =3D self._match_cache.get(cache_key) # cp_list() doesn't expand old-style virtuals if cachelist and cachelist[0].startswith(mycp): return cachelist[:] @@ -51,7 +55,7 @@ class fakedbapi(dbapi): cpv_list =3D [] self._cpv_sort_ascending(cpv_list) if not (not cpv_list and mycp.startswith("virtual/")): - self._match_cache[mycp] =3D cpv_list + self._match_cache[cache_key] =3D cpv_list return cpv_list[:] =20 def cp_all(self):