rebuild_config: propagate runtime deps to parents
authorDavid James <davidjames@chromium.org>
Tue, 3 May 2011 20:10:28 +0000 (13:10 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 3 May 2011 22:47:25 +0000 (15:47 -0700)
Update rebuild option to propagate runtime deps to parents.

Suggested by SebastianLuther@gmx.de

BUG=chromium-os:14858
TEST=Added unit test. Ran unit tests.

Change-Id: I7228a8558eddd1956c590de39430172476c66228

Review URL: http://gerrit.chromium.org/gerrit/202

pym/_emerge/depgraph.py
pym/portage/tests/resolver/test_rebuild.py

index 8a768636500d469f8f2cfbcbfe743c3f79b76afd..0de443b3db978031913bc83b847b4d10d25cb852 100644 (file)
@@ -267,15 +267,21 @@ class _rebuild_config(object):
                        # Remove our leaf node from the graph, keeping track of deps.
                        parents = graph.nodes[node][1].items()
                        graph.remove(node)
+                       node_build_deps = build_deps.get(node, {})
+                       node_runtime_deps = runtime_deps.get(node, {})
                        for parent, priorities in parents:
                                if parent == node:
                                        # Ignore a direct cycle.
                                        continue
+                               parent_bdeps = build_deps.setdefault(parent, {})
+                               parent_rdeps = runtime_deps.setdefault(parent, {})
                                for priority in priorities:
                                        if priority.buildtime:
-                                               build_deps.setdefault(parent, {})[slot_atom] = node
+                                               parent_bdeps[slot_atom] = node
                                        if priority.runtime:
-                                               runtime_deps.setdefault(parent, {})[slot_atom] = node
+                                               parent_rdeps[slot_atom] = node
+                               if slot_atom in parent_bdeps and slot_atom in parent_rdeps:
+                                       parent_rdeps.update(node_runtime_deps)
                                if not graph.child_nodes(parent):
                                        leaf_nodes.append(parent)
 
@@ -284,8 +290,6 @@ class _rebuild_config(object):
                        # completely filled in, and self.rebuild_list / self.reinstall_list
                        # will tell us whether any of our children need to be rebuilt or
                        # reinstalled.
-                       node_build_deps = build_deps.get(node, {})
-                       node_runtime_deps = runtime_deps.get(node, {})
                        if self._trigger_rebuild(node, node_build_deps, node_runtime_deps):
                                need_restart = True
 
index 809dbed6c1bfbe94954d2625bc4c90e18133f8c4..fda289c6e16e82c4d136c0c9763f6281f2264712 100644 (file)
@@ -26,6 +26,8 @@ class RebuildTestCase(TestCase):
                        "sys-apps/d-2": { "RDEPEND" : "sys-libs/x"},
                        "sys-apps/e-2": { "DEPEND"  : "sys-libs/x", "RDEPEND" : "sys-libs/x"},
                        "sys-apps/f-2": { "DEPEND"  : "sys-apps/a", "RDEPEND" : "sys-apps/a"},
+                       "sys-apps/g-2": { "DEPEND"  : "sys-apps/b sys-libs/x",
+                               "RDEPEND" : "sys-apps/b"},
                        }
 
                installed = {
@@ -36,10 +38,12 @@ class RebuildTestCase(TestCase):
                        "sys-apps/d-1": { "RDEPEND" : "sys-libs/x"},
                        "sys-apps/e-1": { "DEPEND"  : "sys-libs/x", "RDEPEND" : "sys-libs/x"},
                        "sys-apps/f-1": { "DEPEND"  : "sys-apps/a", "RDEPEND" : "sys-apps/a"},
+                       "sys-apps/g-1": { "DEPEND"  : "sys-apps/b sys-libs/x",
+                               "RDEPEND" : "sys-apps/b"},
                        }
 
                world = ["sys-apps/a", "sys-apps/b", "sys-apps/c", "sys-apps/d",
-                       "sys-apps/e", "sys-apps/f"]
+                       "sys-apps/e", "sys-apps/f", "sys-apps/g"]
 
                test_cases = (
                                ResolverPlaygroundTestCase(
@@ -53,7 +57,8 @@ class RebuildTestCase(TestCase):
                                ResolverPlaygroundTestCase(
                                        ["sys-libs/x"],
                                        options = {"--rebuild" : True},
-                                       mergelist = ['sys-libs/x-2', 'sys-apps/a-2', 'sys-apps/b-2', 'sys-apps/e-2'],
+                                       mergelist = ['sys-libs/x-2', 'sys-apps/a-2', 'sys-apps/b-2',
+                                               'sys-apps/e-2', 'sys-apps/g-2'],
                                        ignore_mergelist_order = True,
                                        success = True),
                        )