From: Zac Medico Date: Fri, 11 May 2012 23:17:32 +0000 (-0700) Subject: Avoid redundant layout.conf parsing. X-Git-Tag: v2.2.0_alpha104~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=912c564620f59d6e8d0752121c931095ba832ef2;p=portage.git Avoid redundant layout.conf parsing. 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. --- diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py index 9c73612fe..368c0dd15 100644 --- a/pym/portage/package/ebuild/_config/LocationsManager.py +++ b/pym/portage/package/ebuild/_config/LocationsManager.py @@ -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 = \ diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index 45b048cca..1a88250e6 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -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 diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index e544c57f3..371656945 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -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])