_add_pkg: fix existing_node early return
authorZac Medico <zmedico@gentoo.org>
Mon, 11 Feb 2013 22:51:09 +0000 (14:51 -0800)
committerZac Medico <zmedico@gentoo.org>
Mon, 11 Feb 2013 22:51:09 +0000 (14:51 -0800)
This fixes a case where it would return early, before calling
_add_slot_operator_dep, which could prevent slot-operator backtracking
from working properly. This makes SlotChangeWithoutRevBumpTestCase work
properly when we add an undesirable app-arch/libarchive-3.1.1 binary
package.

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

index c3560105c7468ab34a77f6b36bbad71674d896ca..7423ae0be717b18758edc02d5d2e571ad3ceb7b3 100644 (file)
@@ -1653,24 +1653,25 @@ class depgraph(object):
                        if existing_node:
                                if existing_node_matches:
                                        # The existing node can be reused.
-                                       if arg_atoms:
-                                               for parent_atom in arg_atoms:
-                                                       parent, atom = parent_atom
-                                                       self._dynamic_config.digraph.add(existing_node, parent,
-                                                               priority=priority)
-                                                       self._add_parent_atom(existing_node, parent_atom)
-                                       # If a direct circular dependency is not an unsatisfied
-                                       # buildtime dependency then drop it here since otherwise
-                                       # it can skew the merge order calculation in an unwanted
-                                       # way.
-                                       if existing_node != myparent or \
-                                               (priority.buildtime and not priority.satisfied):
-                                               self._dynamic_config.digraph.addnode(existing_node, myparent,
-                                                       priority=priority)
-                                               if dep.atom is not None and dep.parent is not None:
-                                                       self._add_parent_atom(existing_node,
-                                                               (dep.parent, dep.atom))
-                                       return 1
+                                       if pkg != existing_node:
+                                               pkg = existing_node
+                                               previously_added = True
+                                               try:
+                                                       arg_atoms = list(self._iter_atoms_for_pkg(pkg))
+                                               except InvalidDependString as e:
+                                                       if not pkg.installed:
+                                                               # should have been masked before
+                                                               # it was selected
+                                                               raise
+
+                                               if debug:
+                                                       writemsg_level(
+                                                               "%s%s %s\n" % ("Re-used Child:".ljust(15),
+                                                               pkg, pkg_use_display(pkg,
+                                                               self._frozen_config.myopts,
+                                                               modified_use=self._pkg_use_enabled(pkg))),
+                                                               level=logging.DEBUG, noiselevel=-1)
+
                                else:
                                        self._add_slot_conflict(pkg)
                                        if debug:
@@ -1721,12 +1722,19 @@ class depgraph(object):
                if arg_atoms:
                        self._dynamic_config._set_nodes.add(pkg)
 
-               # Do this even when addme is False (--onlydeps) so that the
+               # Do this even for onlydeps, so that the
                # parent/child relationship is always known in case
                # self._show_slot_collision_notice() needs to be called later.
-               self._dynamic_config.digraph.add(pkg, myparent, priority=priority)
-               if dep.atom is not None and dep.parent is not None:
-                       self._add_parent_atom(pkg, (dep.parent, dep.atom))
+               # If a direct circular dependency is not an unsatisfied
+               # buildtime dependency then drop it here since otherwise
+               # it can skew the merge order calculation in an unwanted
+               # way.
+               if pkg != dep.parent or \
+                       (priority.buildtime and not priority.satisfied):
+                       self._dynamic_config.digraph.add(pkg,
+                               dep.parent, priority=priority)
+                       if dep.atom is not None and dep.parent is not None:
+                               self._add_parent_atom(pkg, (dep.parent, dep.atom))
 
                if arg_atoms:
                        for parent_atom in arg_atoms:
index dbd78dc666b9305d60262adf11a4d271f93da6c5..d85ff7e053ad1e837b8d14da8be0a7c81dea3fe2 100644 (file)
@@ -25,6 +25,13 @@ class SlotChangeWithoutRevBumpTestCase(TestCase):
                        },
                }
 
+               binpkgs = {
+                       "app-arch/libarchive-3.1.1" : {
+                               "EAPI": "5",
+                               "SLOT": "0"
+                       },
+               }
+
                installed = {
                        "app-arch/libarchive-3.1.1" : {
                                "EAPI": "5",
@@ -46,13 +53,13 @@ class SlotChangeWithoutRevBumpTestCase(TestCase):
                        # without revbump needs to trigger a rebuild.
                        ResolverPlaygroundTestCase(
                                ["kde-base/ark"],
-                               options = {"--oneshot": True},
+                               options = {"--oneshot": True, "--usepkg": True},
                                success = True,
                                mergelist = ['app-arch/libarchive-3.1.1', "kde-base/ark-4.10.0"]),
 
                )
 
-               playground = ResolverPlayground(ebuilds=ebuilds,
+               playground = ResolverPlayground(ebuilds=ebuilds, binpkgs=binpkgs,
                        installed=installed, world=world, debug=False)
                try:
                        for test_case in test_cases: