* Make depclean/prune use cached Package instances for visibility checks.
authorZac Medico <zmedico@gentoo.org>
Thu, 10 Apr 2008 05:58:59 +0000 (05:58 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 10 Apr 2008 05:58:59 +0000 (05:58 -0000)
* Make FakeVartree wrap dbapi.match() to make sure the metadata in Package
  instances gets updated for any cpv that is returned from a match()
  call, since the metadata can be accessed directly from the Package instance
  instead of via aux_get().

svn path=/main/trunk/; revision=9789

pym/_emerge/__init__.py

index a13ad722521db8c7b4e26baacfbde0749ff9ee38..30df7cb4d6f0a538851047b1ff0711439c180387 100644 (file)
@@ -1026,11 +1026,27 @@ class FakeVartree(portage.vartree):
                # being delayed in case cache generation is triggered.
                self._aux_get = self.dbapi.aux_get
                self.dbapi.aux_get = self._aux_get_wrapper
+               self._match = self.dbapi.match
+               self.dbapi.match = self._match_wrapper
                self._aux_get_history = set()
                self._portdb_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
                self._portdb = portdb
                self._global_updates = None
 
+       def _match_wrapper(self, cpv, use_cache=1):
+               """
+               Make sure the metadata in Package instances gets updated for any
+               cpv that is returned from a match() call, since the metadata can
+               be accessed directly from the Package instance instead of via
+               aux_get().
+               """
+               matches = self._match(cpv, use_cache=use_cache)
+               for cpv in matches:
+                       if cpv in self._aux_get_history:
+                               continue
+                       self._aux_get_wrapper(cpv, [])
+               return matches
+
        def _aux_get_wrapper(self, pkg, wants):
                if pkg in self._aux_get_history:
                        return self._aux_get(pkg, wants)
@@ -6683,10 +6699,8 @@ def action_depclean(settings, trees, ldpath_mtimes,
                        # For consistency with the update algorithm, keep the highest
                        # visible version and prune any versions that are old or masked.
                        for cpv in reversed(pkgs):
-                               metadata = dict(izip(metadata_keys,
-                                       vardb.aux_get(cpv, metadata_keys)))
-                               if visible(settings, Package(built=True, cpv=cpv,
-                                       installed=True, metadata=metadata, type_name="installed")):
+                               if visible(settings,
+                                       pkg_cache[("installed", myroot, cpv, "nomerge")]):
                                        pkgs = [cpv]
                                        break
                        if len(pkgs) > 1: