summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-27 20:43:49 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-27 20:43:49 +0000
commit2641d1772d8170f788d6ce8586b1f97a4506f04b (patch)
tree93fbd5659aea81db4290182e2429907b1a862342
parent65d77297cf1fa8fbf28c26384ef98a7bfae9ec85 (diff)
downloadportage-2641d1772d8170f788d6ce8586b1f97a4506f04b.tar.gz
portage-2641d1772d8170f788d6ce8586b1f97a4506f04b.tar.bz2
portage-2641d1772d8170f788d6ce8586b1f97a4506f04b.zip
Replace depgraph._slot_node_map with _slot_pkg_map so
that it's easier to get existing Package instances. svn path=/main/trunk/; revision=8324
-rw-r--r--pym/_emerge/__init__.py57
1 files changed, 22 insertions, 35 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 5cac1f528..e5ac45cd5 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -883,8 +883,9 @@ def iter_atoms(deps):
yield x
class Package(object):
- __slots__ = ("__weakref__", "built", "cpv", "_digraph_node",
- "installed", "metadata", "root", "onlydeps", "type_name")
+ __slots__ = ("__weakref__", "built", "cpv",
+ "installed", "metadata", "root", "onlydeps", "type_name",
+ "_digraph_node", "_slot_atom")
def __init__(self, **kwargs):
for myattr in self.__slots__:
if myattr == "__weakref__":
@@ -893,6 +894,13 @@ class Package(object):
setattr(self, myattr, myvalue)
@property
+ def slot_atom(self):
+ if self._slot_atom is None:
+ self._slot_atom = "%s:%s" % \
+ (portage.cpv_getkey(self.cpv), self.metadata["SLOT"])
+ return self._slot_atom
+
+ @property
def digraph_node(self):
if self._digraph_node is None:
status = "merge"
@@ -1079,8 +1087,8 @@ class depgraph(object):
self.pkgsettings = {}
# Maps cpv to digraph node for all nodes added to the graph.
self.pkg_node_map = {}
- # Maps slot atom to digraph node for all nodes added to the graph.
- self._slot_node_map = {}
+ # Maps slot atom to package for each Package added to the graph.
+ self._slot_pkg_map = {}
# Maps nodes to the reasons they were selected for reinstallation.
self._reinstall_nodes = {}
self.mydbapi = {}
@@ -1100,7 +1108,7 @@ class depgraph(object):
self.pkgsettings[myroot] = portage.config(
clone=self.trees[myroot]["vartree"].settings)
self.pkg_node_map[myroot] = {}
- self._slot_node_map[myroot] = {}
+ self._slot_pkg_map[myroot] = {}
vardb = self.trees[myroot]["vartree"].dbapi
self.roots[myroot] = RootConfig(self.trees[myroot])
# This fakedbapi instance will model the state that the vdb will
@@ -1366,8 +1374,9 @@ class depgraph(object):
# are being merged in that case.
priority.rebuild = True
- existing_node = self._slot_node_map[myroot].get(
- slot_atom, None)
+ existing_node = self._slot_pkg_map[myroot].get(slot_atom)
+ if existing_node:
+ existing_node = existing_node.digraph_node
slot_collision = False
if existing_node:
e_type, myroot, e_cpv, e_status = existing_node
@@ -1413,8 +1422,8 @@ class depgraph(object):
# function despite collisions.
else:
self.mydbapi[myroot].cpv_inject(mykey, metadata=metadata)
- self._slot_node_map[myroot][slot_atom] = jbigkey
- self.pkg_node_map[myroot][mykey] = jbigkey
+ self._slot_pkg_map[pkg.root][pkg.slot_atom] = pkg
+ self.pkg_node_map[pkg.root][pkg.cpv] = pkg.digraph_node
if rev_dep and myparent:
self.digraph.addnode(myparent, jbigkey,
@@ -2050,26 +2059,6 @@ class depgraph(object):
print xfrom
print
- def _get_existing_pkg(self, root, slot_atom):
- """
- @rtype: Package
- @returns: An existing Package instance added to the graph for the
- given SLOT, or None if no matching package has been added yet.
- """
- existing_node = self._slot_node_map[root].get(slot_atom)
- if not existing_node:
- return None
- e_type, root, e_cpv, e_status = existing_node
- metadata = dict(izip(self._mydbapi_keys,
- self.mydbapi[root].aux_get(e_cpv, self._mydbapi_keys)))
- e_installed = e_type == "installed"
- e_built = e_type != "ebuild"
- e_onlydeps = not e_installed and \
- e_status == "nomerge"
- return Package(cpv=e_cpv, built=e_built,
- installed=e_installed, type_name=e_type,
- metadata=metadata, onlydeps=e_onlydeps, root=root)
-
def _select_package(self, root, atom, onlydeps=False):
pkgsettings = self.pkgsettings[root]
dbs = self._filtered_trees[root]["dbs"]
@@ -2150,7 +2139,7 @@ class depgraph(object):
if find_existing_node:
slot_atom = "%s:%s" % (
portage.cpv_getkey(cpv), metadata["SLOT"])
- e_pkg = self._get_existing_pkg(root, slot_atom)
+ e_pkg = self._slot_pkg_map[root].get(slot_atom)
if not e_pkg:
break
cpv_slot = "%s:%s" % \
@@ -2273,11 +2262,9 @@ class depgraph(object):
myslots = {}
modified_slots[myroot] = myslots
final_db = self.mydbapi[myroot]
- slot_node_map = self._slot_node_map[myroot]
- for slot_atom, mynode in slot_node_map.iteritems():
- mytype, myroot, mycpv, mystatus = mynode
- if mystatus == "merge":
- myslots[slot_atom] = mycpv
+ for pkg in self._slot_pkg_map[myroot].itervalues():
+ if not (pkg.installed or pkg.onlydeps):
+ myslots[pkg.slot_atom] = pkg.cpv
#if "deep" in self.myparams:
if True: