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 9c73612..368c0dd 100644
--- a/pym/portage/package/ebuild/_config/LocationsManager.py
+++ b/pym/portage/package/ebuild/_config/LocationsManager.py
@@ -52,11 +52,20 @@
 		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 45b048c..1a88250 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -427,7 +427,7 @@
 			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 e544c57..3716569 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -49,7 +49,7 @@
 		'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 @@
 			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])