summaryrefslogtreecommitdiffstats
path: root/pym/portage.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-04-27 00:25:51 +0000
committerZac Medico <zmedico@gentoo.org>2008-04-27 00:25:51 +0000
commitf0d3958c46eae8daece64e353e65b1eff9f84df4 (patch)
tree771c477072dfc2b633f85b86b41b7069fa0f4016 /pym/portage.py
parent789e7b1601e33954aa5a81c82affeb90778d6283 (diff)
downloadportage-f0d3958c46eae8daece64e353e65b1eff9f84df4.tar.gz
portage-f0d3958c46eae8daece64e353e65b1eff9f84df4.tar.bz2
portage-f0d3958c46eae8daece64e353e65b1eff9f84df4.zip
Use digraphs to clean up blocker reference counting in the depgraph.
(trunk r9981) svn path=/main/branches/2.1.2/; revision=9987
Diffstat (limited to 'pym/portage.py')
-rw-r--r--pym/portage.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 430c7872c..f11e8877e 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -391,6 +391,28 @@ class digraph:
del self.nodes[node]
self.order.remove(node)
+ def remove_edge(self, child, parent):
+ """
+ Remove edge in the direction from child to parent. Note that it is
+ possible for a remaining edge to exist in the opposite direction.
+ Any endpoint vertices that become isolated will remain in the graph.
+ """
+
+ # Nothing should be modified when a KeyError is raised.
+ for k in parent, child:
+ if k not in self.nodes:
+ raise KeyError(k)
+
+ # Make sure the edge exists.
+ if child not in self.nodes[parent][0]:
+ raise KeyError(child)
+ if parent not in self.nodes[child][1]:
+ raise KeyError(parent)
+
+ # Remove the edge.
+ del self.nodes[child][1][parent]
+ del self.nodes[parent][0][child]
+
def contains(self, node):
"""Checks if the digraph contains mynode"""
return node in self.nodes