From 02a6bf1ac95861831a303f220c7a41b9bbd398ab Mon Sep 17 00:00:00 2001
From: Zac Medico <zmedico@gentoo.org>
Date: Tue, 27 Nov 2012 08:23:46 -0800
Subject: [PATCH] portdbapi: DeprecationWarning for 'pms' cache

---
 pym/portage/dbapi/porttree.py                | 7 +++++++
 pym/portage/repository/config.py             | 2 +-
 pym/portage/tests/dbapi/test_portdb_cache.py | 8 +++++---
 pym/portage/tests/emerge/test_simple.py      | 2 +-
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 115fc7f29..9f0140cdf 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -204,6 +204,13 @@ class portdbapi(dbapi):
 				cache.ec = self.repositories.get_repo_for_location(tree).eclass_db
 			except AttributeError:
 				pass
+
+			if not cache.complete_eclass_entries:
+				warnings.warn(
+					("Repository '%s' used deprecated 'pms' cache format. "
+					"Please migrate to 'md5-dict' format.") % (conf.name,),
+					DeprecationWarning)
+
 		return cache
 
 	def _init_cache_dirs(self):
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index 246be0e8c..3d29fd924 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -201,7 +201,7 @@ class RepoConfig(object):
 			if not force:
 				return
 			# The default egencache format was 'pms' prior to portage-2.1.11.32
-			# (portage versions ersions prior to portage-2.1.11.14 will NOT
+			# (portage versions prior to portage-2.1.11.14 will NOT
 			# recognize md5-dict format unless it is explicitly listed in
 			# layout.conf).
 			formats = ('md5-dict',)
diff --git a/pym/portage/tests/dbapi/test_portdb_cache.py b/pym/portage/tests/dbapi/test_portdb_cache.py
index 3290d08e5..67b961aeb 100644
--- a/pym/portage/tests/dbapi/test_portdb_cache.py
+++ b/pym/portage/tests/dbapi/test_portdb_cache.py
@@ -82,15 +82,17 @@ class PortdbCacheTestCase(TestCase):
 					sys.exit(1)
 			"""),),
 
+			# Don't use python -Wd, since the pms format triggers deprecation warnings
+			# in portdbapi._create_pregen_cache().
 			(BASH_BINARY, "-c", "echo %s > %s" %
 				tuple(map(portage._shell_quote,
 				("cache-formats = pms md5-dict", layout_conf_path,)))),
-			python_cmd + (textwrap.dedent("""
+			(portage_python, "-c") + (textwrap.dedent("""
 				import os, sys, portage
 				if portage.portdb.porttree_root not in portage.portdb._pregen_auxdb:
 					sys.exit(1)
 			"""),),
-			python_cmd + (textwrap.dedent("""
+			(portage_python, "-c") + (textwrap.dedent("""
 				import os, sys, portage
 				from portage.cache.metadata import database as pms_database
 				if not isinstance(portage.portdb._pregen_auxdb[portage.portdb.porttree_root], pms_database):
@@ -173,6 +175,6 @@ class PortdbCacheTestCase(TestCase):
 							sys.stderr.write(_unicode_decode(line))
 
 				self.assertEqual(os.EX_OK, proc.returncode,
-					"command failed with args %s" % (args,))
+					"command %d failed with args %s" % (i, args,))
 		finally:
 			playground.cleanup()
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py
index 56fbdb3bf..a22e2b37d 100644
--- a/pym/portage/tests/emerge/test_simple.py
+++ b/pym/portage/tests/emerge/test_simple.py
@@ -162,7 +162,7 @@ pkg_preinst() {
 		portdir = settings["PORTDIR"]
 		var_cache_edb = os.path.join(eprefix, "var", "cache", "edb")
 		cachedir = os.path.join(var_cache_edb, "dep")
-		cachedir_pregen = os.path.join(portdir, "metadata", "cache")
+		cachedir_pregen = os.path.join(portdir, "metadata", "md5-cache")
 
 		portage_python = portage._python_interpreter
 		ebuild_cmd = (portage_python, "-Wd",
-- 
2.26.2