_serialize_tasks: prefer unsatisfied asap child
authorZac Medico <zmedico@gentoo.org>
Mon, 23 May 2011 05:39:57 +0000 (22:39 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 23 May 2011 05:39:57 +0000 (22:39 -0700)
Optimally, satisfied deps are always merged after the asap nodes that
depend on them.

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

index 37fdeeda3e2796c103de6576ff24b1d3575ce63d..ca1fe0d53916c7ab77036d10bde452406ca7547b 100644 (file)
@@ -4931,6 +4931,7 @@ class depgraph(object):
                                        if nodes:
                                                # If there is a mixture of merges and uninstalls,
                                                # do the uninstalls first.
+                                               good_uninstalls = None
                                                if len(nodes) > 1:
                                                        good_uninstalls = []
                                                        for node in nodes:
@@ -4942,7 +4943,9 @@ class depgraph(object):
                                                        else:
                                                                nodes = nodes
 
-                                               if ignore_priority is None and not tree_mode:
+                                               if good_uninstalls or len(nodes) == 1 or \
+                                                       (ignore_priority is None and \
+                                                       not asap_nodes and not tree_mode):
                                                        # Greedily pop all of these nodes since no
                                                        # relationship has been ignored. This optimization
                                                        # destroys --tree output, so it's disabled in tree
@@ -4955,12 +4958,25 @@ class depgraph(object):
                                                        #    will not produce a leaf node, so avoid it.
                                                        #  * It's normal for a selected uninstall to be a
                                                        #    root node, so don't check them for parents.
-                                                       for node in nodes:
-                                                               if node.operation == "uninstall" or \
-                                                                       mygraph.parent_nodes(node):
-                                                                       selected_nodes = [node]
+                                                       if asap_nodes:
+                                                               prefer_asap_parents = (True, False)
+                                                       else:
+                                                               prefer_asap_parents = (False,)
+                                                       for check_asap_parent in prefer_asap_parents:
+                                                               if check_asap_parent:
+                                                                       for node in nodes:
+                                                                               parents = mygraph.parent_nodes(node,
+                                                                                       ignore_priority=DepPrioritySatisfiedRange.ignore_soft)
+                                                                               if parents and set(parents).intersection(asap_nodes):
+                                                                                       selected_nodes = [node]
+                                                                                       break
+                                                               else:
+                                                                       for node in nodes:
+                                                                               if mygraph.parent_nodes(node):
+                                                                                       selected_nodes = [node]
+                                                                                       break
+                                                               if selected_nodes:
                                                                        break
-
                                                if selected_nodes:
                                                        break
 
index ee3c7863a8334479720cc4c04f14a134c1fd4747..1057300d290cbbaede755eec5eda9f0a2d321c38 100644 (file)
@@ -112,12 +112,13 @@ class MergeOrderTestCase(TestCase):
                        "app-misc/some-app-c-1": {
                                "RDEPEND": "app-misc/circ-buildtime-a app-misc/circ-buildtime-b",
                        },
+                       "app-admin/eselect-python-20100321" : {},
                        "sys-apps/portage-2.1.9.42" : {
                                "DEPEND"  : "dev-lang/python",
                                "RDEPEND" : "dev-lang/python",
                        },
                        "sys-apps/portage-2.1.9.49" : {
-                               "DEPEND"  : "dev-lang/python",
+                               "DEPEND"  : "dev-lang/python >=app-admin/eselect-python-20091230",
                                "RDEPEND" : "dev-lang/python",
                        },
                        "dev-lang/python-3.1" : {},
@@ -318,12 +319,14 @@ class MergeOrderTestCase(TestCase):
                                ["app-misc/blocker-runtime-hard-a"],
                                success = False,
                                mergelist = ['app-misc/blocker-runtime-hard-a-1', '!!app-misc/blocker-runtime-hard-a']),
-                       # Test that PORTAGE_PACKAGE_ATOM is merged asap.
+                       # Test that PORTAGE_PACKAGE_ATOM is merged asap. Optimally,
+                       # satisfied deps are always merged after the asap nodes that
+                       # depend on them.
                        ResolverPlaygroundTestCase(
                                ["dev-lang/python", portage.const.PORTAGE_PACKAGE_ATOM],
                                success = True,
                                all_permutations = True,
-                               mergelist = ['sys-apps/portage-2.1.9.49', 'dev-lang/python-3.2']),
+                               mergelist = ['app-admin/eselect-python-20100321', 'sys-apps/portage-2.1.9.49', 'dev-lang/python-3.2']),
                        # Test that OS_HEADERS_PACKAGE_ATOM and LIBC_PACKAGE_ATOM
                        # are merged asap, in order to account for implicit
                        # dependencies. See bug #303567.