Avoid redundant layout.conf parsing.
authorZac Medico <zmedico@gentoo.org>
Fri, 11 May 2012 23:17:32 +0000 (16:17 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 11 May 2012 23:17:32 +0000 (16:17 -0700)
By passing the RepoConfigLoader instance into LocationsManager, we can
re-use previously parsed layout.conf data. The RepoConfigLoader
instance will also be useful for bug #414961.

pym/portage/package/ebuild/_config/LocationsManager.py
pym/portage/package/ebuild/config.py
pym/portage/repository/config.py

index 9c73612fed9e46b2fd1ae13cc90dd9cbb3820182..368c0dd159d0e355e273c0dc50acea16d48a98e2 100644 (file)
@@ -52,11 +52,20 @@ class LocationsManager(object):
                self.abs_user_config = os.path.join(self.config_root, USER_CONFIG_PATH)
                self.config_profile_path = config_profile_path
 
-       def load_profiles(self, known_repository_paths):
-               known_repos = set(os.path.realpath(x) for x in known_repository_paths)
-               # force a trailing '/' for ease of doing startswith checks
-               known_repos = tuple((x + '/', parse_layout_conf(x)[0])
-                       for x in known_repos)
+       def load_profiles(self, repositories, known_repository_paths):
+               known_repository_paths = set(os.path.realpath(x)
+                       for x in known_repository_paths)
+
+               known_repos = []
+               for x in known_repository_paths:
+                       try:
+                               layout_data = {"profile-formats":
+                                       repositories.get_repo_for_location(x).profile_formats}
+                       except KeyError:
+                               layout_data = parse_layout_conf(x)[0]
+                       # force a trailing '/' for ease of doing startswith checks
+                       known_repos.append((x + '/', layout_data))
+               known_repos = tuple(known_repos)
 
                if self.config_profile_path is None:
                        self.config_profile_path = \
index 45b048ccad33212f17968635abbaacae507417f4..1a88250e6d17c43c9a102739e37681f15b62e188 100644 (file)
@@ -427,7 +427,7 @@ class config(object):
                        self.lookuplist = [self.configdict["env"]]
                        self.repositories = load_repository_config(self)
 
-                       locations_manager.load_profiles(known_repos)
+                       locations_manager.load_profiles(self.repositories, known_repos)
 
                        profiles_complex = locations_manager.profiles_complex
                        self.profiles = locations_manager.profiles
index e544c57f3ab8b208c77c41a430b0fa06ff6a45d5..3716569452b562e1af898b379980481235a27fb3 100644 (file)
@@ -49,7 +49,7 @@ class RepoConfig(object):
                'cache_formats', 'create_manifest', 'disable_manifest', 'eapi',
                'eclass_db', 'eclass_locations', 'eclass_overrides', 'format', 'location',
                'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name',
-               'name', 'priority', 'sign_commit', 'sign_manifest', 'sync', 'thin_manifest',
+               'name', 'priority', 'profile_formats', 'sign_commit', 'sign_manifest', 'sync', 'thin_manifest',
                'update_changelog', 'user_location', 'portage1_profiles',
                'portage1_profiles_compat')
 
@@ -153,6 +153,7 @@ class RepoConfig(object):
                        for value in ('allow-missing-manifest',
                                'allow-provide-virtual', 'cache-formats',
                                'create-manifest', 'disable-manifest', 'manifest-hashes',
+                               'profile-formats',
                                'sign-commit', 'sign-manifest', 'thin-manifest', 'update-changelog'):
                                setattr(self, value.lower().replace("-", "_"), layout_data[value])