public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/dbapi/, pym/portage/repository/
@ 2012-09-08  4:32 Zac Medico
  0 siblings, 0 replies; only message in thread
From: Zac Medico @ 2012-09-08  4:32 UTC (permalink / raw
  To: gentoo-commits

commit:     24b7ebe3b9404f0344f5b34eb322abde64143263
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Sep  8 04:32:03 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Sep  8 04:32:03 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=24b7ebe3

Detect md5-cache when no cache-formats specified.

Auto-detect cache-formats from the corresponding directories when
cache-formats is not specifed in layout.conf, and prefer md5-dict if
available. After this behavior is deployed in stable portage, the
default egencache format can be changed to md5-dict.

---
 pym/portage/repository/config.py             |   12 +++++++++---
 pym/portage/tests/dbapi/test_portdb_cache.py |   15 +++++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index 9b43f38..4de49f0 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -713,9 +713,15 @@ def parse_layout_conf(repo_location, repo_name=None):
 	# for compatibility w/ PMS, fallback to pms; but also check if the
 	# cache exists or not.
 	cache_formats = layout_data.get('cache-formats', '').lower().split()
-	if not cache_formats and os.path.isdir(
-		os.path.join(repo_location, 'metadata', 'cache')):
-		cache_formats = ['pms']
+	if not cache_formats:
+		# Auto-detect cache formats, and prefer md5-cache if available.
+		# After this behavior is deployed in stable portage, the default
+		# egencache format can be changed to md5-dict.
+		cache_formats = []
+		if os.path.isdir(os.path.join(repo_location, 'metadata', 'md5-cache')):
+			cache_formats.append('md5-dict')
+		if os.path.isdir(os.path.join(repo_location, 'metadata', 'cache')):
+			cache_formats.append('pms')
 	data['cache-formats'] = tuple(cache_formats)
 
 	manifest_hashes = layout_data.get('manifest-hashes')

diff --git a/pym/portage/tests/dbapi/test_portdb_cache.py b/pym/portage/tests/dbapi/test_portdb_cache.py
index e6d2ba7..4a0129b 100644
--- a/pym/portage/tests/dbapi/test_portdb_cache.py
+++ b/pym/portage/tests/dbapi/test_portdb_cache.py
@@ -96,6 +96,21 @@ class PortdbCacheTestCase(TestCase):
 				if not isinstance(portage.portdb._pregen_auxdb[portage.portdb.porttree_root], pms_database):
 					sys.exit(1)
 			"""),),
+
+			# Test auto-detection and preference for md5-cache when both
+			# cache formats are available but layout.conf is absent.
+			(BASH_BINARY, "-c", "rm %s" % portage._shell_quote(layout_conf_path)),
+			python_cmd + (textwrap.dedent("""
+				import os, sys, portage
+				if portage.portdb.porttree_root not in portage.portdb._pregen_auxdb:
+					sys.exit(1)
+			"""),),
+			python_cmd + (textwrap.dedent("""
+				import os, sys, portage
+				from portage.cache.flat_hash import md5_database
+				if not isinstance(portage.portdb._pregen_auxdb[portage.portdb.porttree_root], md5_database):
+					sys.exit(1)
+			"""),),
 		)
 
 		features = []


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-09-08  4:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-08  4:32 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/dbapi/, pym/portage/repository/ Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox