When backtracking due to an unsatisfied dependency, show a normal unsatisfied
authorZac Medico <zmedico@gentoo.org>
Tue, 28 Jul 2009 23:27:52 +0000 (23:27 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 28 Jul 2009 23:27:52 +0000 (23:27 -0000)
dependency message for the given atom. Thanks to Thomas Sachau
<tommy@gentoo.org> for reporting.

svn path=/main/trunk/; revision=13852

pym/_emerge/depgraph.py

index dc74b3669bb25523f520df94aa14d1f467037614..527b2f9fa649fca4d0db3415793de386dca463f9 100644 (file)
@@ -276,6 +276,8 @@ class depgraph(object):
                        '--debug' not in self._frozen_config.myopts:
                        return
 
+               # In order to minimize noise, show only the highest
+               # missed update from each SLOT.
                missed_updates = {}
                for pkg, mask_reasons in \
                        self._dynamic_config._runtime_pkg_mask.iteritems():
@@ -284,15 +286,54 @@ class depgraph(object):
                                # want to show available updates.
                                continue
                        if pkg.slot_atom in missed_updates:
-                               other_pkg, parent_atoms = missed_updates[pkg.slot_atom]
+                               other_pkg, mask_type, parent_atoms = \
+                                       missed_updates[pkg.slot_atom]
                                if other_pkg > pkg:
                                        continue
                        for mask_type, parent_atoms in mask_reasons.iteritems():
                                if not parent_atoms:
                                        continue
-                               missed_updates[pkg.slot_atom] = (pkg, parent_atoms)
+                               missed_updates[pkg.slot_atom] = (pkg, mask_type, parent_atoms)
                                break
 
+               if not missed_updates:
+                       return
+
+               missed_update_types = {}
+               for pkg, mask_type, parent_atoms in missed_updates.itervalues():
+                       missed_update_types.setdefault(mask_type,
+                               []).append((pkg, parent_atoms))
+
+               self._show_missed_update_slot_conflicts(
+                       missed_update_types.get("slot conflict"))
+
+               self._show_missed_update_unsatisfied_dep(
+                       missed_update_types.get("missing dependency"))
+
+       def _show_missed_update_unsatisfied_dep(self, missed_updates):
+
+               if not missed_updates:
+                       return
+
+               write = sys.stderr.write
+
+               for pkg, parent_atoms in missed_updates:
+
+                       write("\n!!! The following update has been skipped " + \
+                               "due to unsatisfied dependencies:\n\n")
+
+                       write(str(pkg.slot_atom))
+                       write("\n")
+
+                       for parent, atom in parent_atoms:
+                               # TODO: Account for which $ROOT the atom applies to.
+                               self._show_unsatisfied_dep(parent.root, atom, myparent=parent)
+                               write("\n")
+
+               sys.stderr.flush()
+
+       def _show_missed_update_slot_conflicts(self, missed_updates):
+
                if not missed_updates:
                        return
 
@@ -301,7 +342,7 @@ class depgraph(object):
                        "a dependency conflict:\n\n")
 
                indent = "  "
-               for pkg, parent_atoms in missed_updates.itervalues():
+               for pkg, parent_atoms in missed_updates:
                        msg.append(str(pkg.slot_atom))
                        msg.append("\n\n")
 
@@ -1932,6 +1973,11 @@ class depgraph(object):
                        traversed_nodes.add(node)
                        msg.append('(dependency required by "%s" [%s])' % \
                                (colorize('INFORM', str(node.cpv)), node.type_name))
+
+                       if node not in self._dynamic_config.digraph:
+                               # The parent is not in the graph due to backtracking.
+                               break
+
                        # When traversing to parents, prefer arguments over packages
                        # since arguments are root nodes. Never traverse the same
                        # package twice, in order to prevent an infinite loop.