Bug #285832 - When updates are missed due to dependencies that have been
authorZac Medico <zmedico@gentoo.org>
Sat, 3 Oct 2009 04:03:16 +0000 (04:03 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 3 Oct 2009 04:03:16 +0000 (04:03 -0000)
masked by backtracking, abbreviate output in order to avoid terminal
flooding.

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

pym/_emerge/depgraph.py

index 47da7f725f31c61e0107d5d736f2879010878de2..2cc9e170afa290bba83e2cd2912b17c5160995a0 100644 (file)
@@ -318,9 +318,19 @@ class depgraph(object):
                        return
 
                write = sys.stderr.write
+               backtrack_masked = []
 
                for pkg, parent_atoms in missed_updates:
 
+                       try:
+                               for parent, root, atom in parent_atoms:
+                                       self._show_unsatisfied_dep(root, atom, myparent=parent,
+                                               check_backtrack=True)
+                       except self._backtrack_mask:
+                               # This is displayed below in abbreviated form.
+                               backtrack_masked.append((pkg, parent_atoms))
+                               continue
+
                        write("\n!!! The following update has been skipped " + \
                                "due to unsatisfied dependencies:\n\n")
 
@@ -333,6 +343,18 @@ class depgraph(object):
                                self._show_unsatisfied_dep(root, atom, myparent=parent)
                                write("\n")
 
+               if backtrack_masked:
+                       # These are shown in abbreviated form, in order to avoid terminal
+                       # flooding from mask messages as reported in bug #285832.
+                       write("\n!!! The following update(s) have been skipped " + \
+                               "due to unsatisfied dependencies\n" + \
+                               "!!! triggered by backtracking:\n\n")
+                       for pkg, parent_atoms in backtrack_masked:
+                               write(str(pkg.slot_atom))
+                               if pkg.root != '/':
+                                       write(" for %s" % (pkg.root,))
+                               write("\n")
+
                sys.stderr.flush()
 
        def _show_missed_update_slot_conflicts(self, missed_updates):
@@ -1993,7 +2015,14 @@ class depgraph(object):
 
                return selected_atoms
 
-       def _show_unsatisfied_dep(self, root, atom, myparent=None, arg=None):
+       def _show_unsatisfied_dep(self, root, atom, myparent=None, arg=None,
+               check_backtrack=False):
+               """
+               When check_backtrack=True, no output is produced and
+               the method either returns or raises _backtrack_mask if
+               a matching package has been masked by backtracking.
+               """
+               backtrack_mask = False
                atom_set = InternalPackageSet(initial_atoms=(atom,))
                xinfo = '"%s"' % atom
                if arg:
@@ -2038,6 +2067,7 @@ class depgraph(object):
                                                        self._dynamic_config._runtime_pkg_mask[pkg]
                                                mreasons.append('backtracking: %s' % \
                                                        ', '.join(sorted(backtrack_reasons)))
+                                               backtrack_mask = True
                                        if mreasons:
                                                masked_pkg_instances.add(pkg)
                                        if atom.use:
@@ -2047,6 +2077,12 @@ class depgraph(object):
                                masked_packages.append(
                                        (root_config, pkgsettings, cpv, metadata, mreasons))
 
+               if check_backtrack:
+                       if backtrack_mask:
+                               raise self._backtrack_mask()
+                       else:
+                               return
+
                missing_use_reasons = []
                missing_iuse_reasons = []
                for pkg in missing_use:
@@ -4933,6 +4969,13 @@ class depgraph(object):
                graph in order to avoid making a potentially unsafe decision.
                """
 
+       class _backtrack_mask(_internal_exception):
+               """
+               This is raised by _show_unsatisfied_dep() when it's called with
+               check_backtrack=True and a matching package has been masked by
+               backtracking.
+               """
+
        def need_restart(self):
                return self._dynamic_config._need_restart