public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/_emerge/
Date: Sat, 21 Apr 2012 06:51:27 +0000 (UTC)	[thread overview]
Message-ID: <1334990731.d603f1440c814377fbc1965729fd9b6b008cf76d.zmedico@gentoo> (raw)

commit:     d603f1440c814377fbc1965729fd9b6b008cf76d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 21 06:38:17 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Apr 21 06:45:31 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d603f144

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/PackageVirtualDbapi.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
 
 import sys
 from portage.dbapi import dbapi
+from portage.dbapi.dep_expand import dep_expand
 
 class PackageVirtualDbapi(dbapi):
 	"""
@@ -76,18 +77,21 @@ class PackageVirtualDbapi(dbapi):
 			self._match_cache = {}
 
 	def match(self, origdep, use_cache=1):
-		result = self._match_cache.get(origdep)
+		atom = dep_expand(origdep, mydb=self, settings=self.settings)
+		cache_key = (atom, atom.unevaluated_atom)
+		result = self._match_cache.get(cache_key)
 		if result is not None:
 			return result[:]
-		result = dbapi.match(self, origdep, use_cache=use_cache)
-		self._match_cache[origdep] = result
+		result = list(self._iter_match(atom, self.cp_list(atom.cp)))
+		self._match_cache[cache_key] = result
 		return result[:]
 
 	def cpv_exists(self, cpv, myrepo=None):
 		return cpv in self._cpv_map
 
 	def cp_list(self, mycp, use_cache=1):
-		cachelist = self._match_cache.get(mycp)
+		cache_key = (mycp, mycp)
+		cachelist = 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 = [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] = cpv_list
+			self._match_cache[cache_key] = cpv_list
 		return cpv_list[:]
 
 	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
 
 	def match(self, atom):
-		ret = self._match_cache.get(atom)
+		cache_key = (atom, atom.unevaluated_atom)
+		ret = self._match_cache.get(cache_key)
 		if ret is not None:
 			return ret[:]
 
@@ -6801,7 +6802,7 @@ class _dep_check_composite_db(dbapi):
 			if len(ret) > 1:
 				self._cpv_sort_ascending(ret)
 
-		self._match_cache[atom] = ret
+		self._match_cache[cache_key] = ret
 		return ret[:]
 
 	def _visible(self, pkg):

diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
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
 
 __all__ = [
@@ -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] = cachelist
+					self.xcache["match-all"][(mycp, mycp)] = cachelist
 				return cachelist[:]
 		mysplit = mycp.split("/")
 		invalid_category = 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] = cachelist
+				self.xcache["match-all"][(mycp, mycp)] = cachelist
 		return mylist
 
 	def freeze(self):
@@ -809,19 +809,21 @@ class portdbapi(dbapi):
 				"has been renamed to match-visible",
 				DeprecationWarning, stacklevel=2)
 
-		#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 = dep_expand(origdep, mydb=self, settings=self.settings)
 			mykey = mydep.cp
 
+		#if no updates are being made to the tree, we can consult our xcache...
+		cache_key = None
+		if self.frozen:
+			cache_key = (mydep, mydep.unevaluated_atom)
+			try:
+				return self.xcache[level][cache_key][:]
+			except KeyError:
+				pass
+
 		myval = None
 		mytree = None
 		if mydep.repo is not None:
@@ -930,9 +932,7 @@ class portdbapi(dbapi):
 		if self.frozen:
 			xcache_this_level = self.xcache.get(level)
 			if xcache_this_level is not None:
-				xcache_this_level[mydep] = myval
-				if origdep and origdep != mydep:
-					xcache_this_level[origdep] = myval
+				xcache_this_level[cache_key] = myval
 				myval = myval[:]
 
 		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 = dep_expand(
 			origdep, mydb=self, use_cache=use_cache, settings=self.settings)
+		cache_key = (mydep, mydep.unevaluated_atom)
 		mykey = dep_getkey(mydep)
 		mycat = catsplit(mykey)[0]
 		if not use_cache:
@@ -505,8 +506,8 @@ class vardbapi(dbapi):
 		if mydep not in self.matchcache[mycat]:
 			mymatch = list(self._iter_match(mydep,
 				self.cp_list(mydep.cp, use_cache=use_cache)))
-			self.matchcache[mycat][mydep] = mymatch
-		return self.matchcache[mycat][mydep][:]
+			self.matchcache[mycat][cache_key] = mymatch
+		return self.matchcache[mycat][cache_key][:]
 
 	def findname(self, mycpv, myrepo=None):
 		return self.getpath(str(mycpv), filename=catsplit(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
 
 
 from portage.dbapi import dbapi
+from portage.dbapi.dep_expand import dep_expand
 from portage import cpv_getkey
 
 class fakedbapi(dbapi):
@@ -31,18 +32,21 @@ class fakedbapi(dbapi):
 			self._match_cache = {}
 
 	def match(self, origdep, use_cache=1):
-		result = self._match_cache.get(origdep, None)
+		atom = dep_expand(origdep, mydb=self, settings=self.settings)
+		cache_key = (atom, atom.unevaluated_atom)
+		result = self._match_cache.get(cache_key)
 		if result is not None:
 			return result[:]
-		result = dbapi.match(self, origdep, use_cache=use_cache)
-		self._match_cache[origdep] = result
+		result = list(self._iter_match(atom, self.cp_list(atom.cp)))
+		self._match_cache[cache_key] = result
 		return result[:]
 
 	def cpv_exists(self, mycpv, myrepo=None):
 		return mycpv in self.cpvdict
 
 	def cp_list(self, mycp, use_cache=1, myrepo=None):
-		cachelist = self._match_cache.get(mycp)
+		cache_key = (mycp, mycp)
+		cachelist = 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 = []
 		self._cpv_sort_ascending(cpv_list)
 		if not (not cpv_list and mycp.startswith("virtual/")):
-			self._match_cache[mycp] = cpv_list
+			self._match_cache[cache_key] = cpv_list
 		return cpv_list[:]
 
 	def cp_all(self):



             reply	other threads:[~2012-04-21  6:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-21  6:51 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-04-03 20:03 [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/_emerge/ Zac Medico
2015-08-30 23:44 Zac Medico
2014-11-20  4:08 Zac Medico
2014-02-24  9:23 Alexander Berntsen
2013-03-13  5:56 Zac Medico
2013-01-23 16:19 Zac Medico
2013-01-05 15:20 Zac Medico
2012-12-23  5:33 Arfrever Frehtes Taifersar Arahesis
2012-11-24 21:57 Zac Medico
2012-04-22 18:57 Zac Medico
2012-02-17 22:19 Zac Medico
2012-02-16  0:33 Zac Medico
2012-02-14 23:40 Zac Medico
2012-02-10  1:28 Zac Medico
2012-02-08  1:16 Zac Medico
2012-02-08  0:36 Zac Medico
2011-10-28  2:34 Zac Medico
2011-10-16 20:26 Zac Medico
2011-10-15  5:10 Zac Medico
2011-06-03 10:16 Zac Medico
2011-05-24  5:31 Zac Medico
2011-05-24  0:33 Zac Medico
2011-05-09  5:16 Zac Medico
2011-03-26  7:39 Zac Medico
2011-03-26  3:24 Zac Medico
2011-03-25  4:34 Zac Medico
2011-03-25  4:34 Zac Medico
2011-03-25  4:34 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1334990731.d603f1440c814377fbc1965729fd9b6b008cf76d.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox