From: Arfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>
Date: Fri, 9 Dec 2011 04:43:20 +0000 (+0100)
Subject: Add eclass_db attribute in portage.repository.config.RepoConfig objects.
X-Git-Tag: v2.2.0_alpha80~47
X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4e87ba4eb94c0ad1615c9926650a8925d5688393;p=portage.git

Add eclass_db attribute in portage.repository.config.RepoConfig objects.
---

diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 15f1faf3a..94961dda1 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -111,7 +111,7 @@ class portdbapi(dbapi):
 					":".join(filter(None, sandbox_write))
 
 		self.porttrees = list(self.settings.repositories.repoLocationList())
-		self.eclassdb = eclass_cache.cache(self.settings.repositories.mainRepoLocation())
+		self.eclassdb = self.repositories.mainRepo().eclass_db
 
 		# This is used as sanity check for aux_get(). If there is no
 		# root eclass dir, we assume that PORTDIR is invalid or
@@ -126,23 +126,11 @@ class portdbapi(dbapi):
 
 		#Create eclass dbs
 		self._repo_info = {}
-		eclass_dbs = {self.settings.repositories.mainRepoLocation() : self.eclassdb}
 		for repo in self.repositories:
 			if repo.location in self._repo_info:
 				continue
 
-			eclass_db = None
-			for eclass_location in repo.eclass_locations:
-				tree_db = eclass_dbs.get(eclass_location)
-				if tree_db is None:
-					tree_db = eclass_cache.cache(eclass_location)
-					eclass_dbs[eclass_location] = tree_db
-				if eclass_db is None:
-					eclass_db = tree_db.copy()
-				else:
-					eclass_db.append(tree_db)
-
-			self._repo_info[repo.location] = _repo_info(repo.name, repo.location, eclass_db)
+			self._repo_info[repo.location] = _repo_info(repo.name, repo.location, repo.eclass_db)
 
 		#Keep a list of repo names, sorted by priority (highest priority first).
 		self._ordered_repo_name_list = tuple(reversed(self.repositories.prepos_order))
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index ed0f64dde..4a8d8666e 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -15,7 +15,7 @@ try:
 		from configparser import SafeConfigParser
 except ImportError:
 	from ConfigParser import SafeConfigParser, ParsingError
-from portage import os
+from portage import eclass_cache, os
 from portage.const import (MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH,
 	REPO_NAME_LOC, USER_CONFIG_PATH)
 from portage.env.loaders import KeyValuePairFileLoader
@@ -47,7 +47,7 @@ class RepoConfig(object):
 
 	__slots__ = ('aliases', 'allow_missing_manifest',
 		'cache_formats', 'create_manifest', 'disable_manifest',
-		'eclass_overrides', 'eclass_locations', 'format', 'location',
+		'eclass_db', 'eclass_locations', 'eclass_overrides', 'format', 'location',
 		'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name',
 		'name', 'priority', 'sign_manifest', 'sync', 'thin_manifest',
 		'update_changelog', 'user_location', 'portage1_profiles',
@@ -66,7 +66,8 @@ class RepoConfig(object):
 		if eclass_overrides is not None:
 			eclass_overrides = tuple(eclass_overrides.split())
 		self.eclass_overrides = eclass_overrides
-		#Locations are computed later.
+		# Eclass databases and locations are computed later.
+		self.eclass_db = None
 		self.eclass_locations = None
 
 		# Masters from repos.conf override layout.conf.
@@ -543,6 +544,23 @@ class RepoConfigLoader(object):
 							level=logging.ERROR, noiselevel=-1)
 			repo.eclass_locations = tuple(eclass_locations)
 
+		eclass_dbs = {}
+		for repo_name, repo in prepos.items():
+			if repo_name == "DEFAULT":
+				continue
+
+			eclass_db = None
+			for eclass_location in repo.eclass_locations:
+				tree_db = eclass_dbs.get(eclass_location)
+				if tree_db is None:
+					tree_db = eclass_cache.cache(eclass_location)
+					eclass_dbs[eclass_location] = tree_db
+				if eclass_db is None:
+					eclass_db = tree_db.copy()
+				else:
+					eclass_db.append(tree_db)
+			repo.eclass_db = eclass_db
+
 		self._prepos_changed = True
 		self._repo_location_list = []