summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-09-22 08:11:31 +0000
committerZac Medico <zmedico@gentoo.org>2006-09-22 08:11:31 +0000
commit9af77830aec672ebf3f8a86735a9b1c91922e4dd (patch)
tree65436915fbf6be0d210cddb6a29c23398765f2d9
parent86d478180e773d76da5610fc3dcbe16eb10eef57 (diff)
downloadportage-9af77830aec672ebf3f8a86735a9b1c91922e4dd.tar.gz
portage-9af77830aec672ebf3f8a86735a9b1c91922e4dd.tar.bz2
portage-9af77830aec672ebf3f8a86735a9b1c91922e4dd.zip
Allow packages specified on the command line to be retroactively upgraded from "nomerge" to "merge" nodes.
svn path=/main/trunk/; revision=4494
-rwxr-xr-xbin/emerge2
-rw-r--r--pym/portage.py26
2 files changed, 28 insertions, 0 deletions
diff --git a/bin/emerge b/bin/emerge
index 7bf35f190..a8af02919 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -721,6 +721,8 @@ class depgraph:
self.digraph.addnode(myparent, jbigkey, soft_dep=soft_dep)
else:
self.digraph.addnode(jbigkey, myparent, soft_dep=soft_dep)
+ if arg:
+ self.digraph.replace(jbigkey, " ".join(mybigkey) + " merge")
return 1
self.spinner.update()
diff --git a/pym/portage.py b/pym/portage.py
index 104f1a279..a97c50171 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -364,6 +364,32 @@ class digraph:
del self.nodes[node]
self.order.remove(node)
+ def replace(self, oldnode, newnode):
+ """Replace all references to oldnode with references to newnode.
+ This is useful for upgrading a "nomerge" node to a "merge" node.
+
+ @return:
+ 1. None on success.
+ 2. Raise a KeyError if oldnode does not exist.
+ 3. Raise a ValueError if newnode already exists.
+ """
+ if not self.contains(oldnode):
+ raise KeyError(oldnode)
+ if oldnode == newnode:
+ return
+ if newnode in self.nodes:
+ raise ValueError(newnode)
+ for parent in self.nodes[oldnode][1]:
+ self.nodes[parent][0][newnode] = self.nodes[parent][0][oldnode]
+ del self.nodes[parent][0][oldnode]
+ for child in self.nodes[oldnode][0]:
+ self.nodes[child][1][newnode] = self.nodes[child][1][oldnode]
+ del self.nodes[child][1][oldnode]
+ self.nodes[newnode] = self.nodes[oldnode]
+ del self.nodes[oldnode]
+ oldindex = self.order.index(oldnode)
+ self.order[oldindex] = newnode
+
def contains(self, node):
"""Checks if the digraph contains mynode"""
return node in self.nodes