* Make depclean/prune use cached Package instances for visibility checks.
authorZac Medico <zmedico@gentoo.org>
Thu, 10 Apr 2008 06:15:24 +0000 (06:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 10 Apr 2008 06:15:24 +0000 (06:15 -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().
(trunk r9789)

svn path=/main/branches/2.1.2/; revision=9793

bin/emerge

index daab0e780bd59d7f0d74b536bc124e8c75a7aff7..4501731db7d308d2e45b12bd8c94c50ea6efa634 100755 (executable)
@@ -1188,11 +1188,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)
@@ -6688,10 +6704,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: