When adding blockers for installed packages to the graph, use cached
authorZac Medico <zmedico@gentoo.org>
Thu, 1 May 2008 19:20:44 +0000 (19:20 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 1 May 2008 19:20:44 +0000 (19:20 -0000)
Package instances instead of constructing new ones. (trunk r10062)

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

bin/emerge

index d25f2e60522e2f71538d4b163d049e13d03a9a7e..f7fcc863ebd0f4b2dcc98c63f8278dd1eff4934b 100755 (executable)
@@ -3296,19 +3296,14 @@ class depgraph(object):
                                final_db = self.mydbapi[myroot]
                                cpv_all_installed = self.trees[myroot]["vartree"].dbapi.cpv_all()
                                blocker_cache = BlockerCache(myroot, vardb)
-                               for pkg in cpv_all_installed:
+                               for cpv in cpv_all_installed:
                                        blocker_atoms = None
-                                       metadata = dict(izip(self._mydbapi_keys,
-                                               vardb.aux_get(pkg, self._mydbapi_keys)))
-                                       node = Package(cpv=pkg, built=True,
-                                               installed=True, metadata=metadata,
-                                               type_name="installed", root=myroot)
-
-                                       
+                                       pkg = self._pkg_cache[
+                                               ("installed", myroot, cpv, "nomerge")]
                                        blockers = None
-                                       if self.digraph.contains(node):
+                                       if self.digraph.contains(pkg):
                                                try:
-                                                       blockers = self._blocker_parents.child_nodes(node)
+                                                       blockers = self._blocker_parents.child_nodes(pkg)
                                                except KeyError:
                                                        blockers = []
                                        if blockers is not None:
@@ -3318,7 +3313,7 @@ class depgraph(object):
                                        # If this node has any blockers, create a "nomerge"
                                        # node for it so that they can be enforced.
                                        self.spinner.update()
-                                       blocker_data = blocker_cache.get(pkg)
+                                       blocker_data = blocker_cache.get(cpv)
 
                                        # If blocker data from the graph is available, use
                                        # it to validate the cache and update the cache if
@@ -3343,9 +3338,8 @@ class depgraph(object):
                                        if blocker_data:
                                                blocker_atoms = blocker_data.atoms
                                        else:
-                                               dep_vals = vardb.aux_get(pkg, dep_keys)
-                                               myuse = vardb.aux_get(pkg, ["USE"])[0].split()
-                                               depstr = " ".join(dep_vals)
+                                               myuse = pkg.metadata["USE"].split()
+                                               depstr = " ".join(pkg.metadata[k] for k in dep_keys)
                                                # It is crucial to pass in final_db here in order to
                                                # optimize dep_check calls by eliminating atoms via
                                                # dep_wordreduce and dep_eval calls.
@@ -3363,32 +3357,30 @@ class depgraph(object):
                                                                # matches (this can happen if an atom lacks a
                                                                # category).
                                                                show_invalid_depstring_notice(
-                                                                       node, depstr, str(e))
+                                                                       pkg, depstr, str(e))
                                                                del e
                                                                raise
                                                finally:
                                                        portage_dep._dep_check_strict = True
                                                if not success:
-                                                       slot_atom = "%s:%s" % (portage.dep_getkey(pkg),
-                                                               vardb.aux_get(pkg, ["SLOT"])[0])
-                                                       if slot_atom in modified_slots[myroot]:
+                                                       if pkg.slot_atom in modified_slots[myroot]:
                                                                # This package is being replaced anyway, so
                                                                # ignore invalid dependencies so as not to
                                                                # annoy the user too much (otherwise they'd be
                                                                # forced to manually unmerge it first).
                                                                continue
-                                                       show_invalid_depstring_notice(node, depstr, atoms)
+                                                       show_invalid_depstring_notice(pkg, depstr, atoms)
                                                        return False
                                                blocker_atoms = [myatom for myatom in atoms \
                                                        if myatom.startswith("!")]
                                                blocker_atoms.sort()
-                                               counter = long(vardb.aux_get(pkg, ["COUNTER"])[0])
-                                               blocker_cache[pkg] = \
+                                               counter = long(pkg.metadata["COUNTER"])
+                                               blocker_cache[cpv] = \
                                                        blocker_cache.BlockerData(counter, blocker_atoms)
                                        if blocker_atoms:
                                                for myatom in blocker_atoms:
                                                        blocker = Blocker(atom=myatom[1:], root=myroot)
-                                                       self._blocker_parents.add(blocker, node)
+                                                       self._blocker_parents.add(blocker, pkg)
                                blocker_cache.flush()
                                del blocker_cache