depgraph: make downgrades trigger complete graph
authorZac Medico <zmedico@gentoo.org>
Fri, 4 Feb 2011 17:41:30 +0000 (09:41 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 4 Feb 2011 17:46:24 +0000 (09:46 -0800)
It's common for downgrades to break dependencies, as in bug #353613, so
automatically trigger complete graph mode when a downgrade is found.

pym/_emerge/depgraph.py

index 5380de15b64a76727d6b0497e045a85348149003..7b74a265e910576cf3b5320e06fe2082f682c35a 100644 (file)
@@ -3408,8 +3408,27 @@ class depgraph(object):
                        return 1
 
                if "complete" not in self._dynamic_config.myparams:
-                       # Skip this to avoid consuming enough time to disturb users.
-                       return 1
+                       # Automatically enable complete mode if there are any
+                       # downgrades, since they often break dependencies
+                       # (like in bug #353613).
+                       have_downgrade = False
+                       for node in self._dynamic_config.digraph:
+                               if not isinstance(node, Package) or \
+                                       node.operation != "merge":
+                                       continue
+                               vardb = self._frozen_config.roots[
+                                       node.root].trees["vartree"].dbapi
+                               inst_pkg = vardb.match_pkgs(node.slot_atom)
+                               if inst_pkg and inst_pkg[0] > node:
+                                       have_downgrade = True
+                                       break
+
+                       if have_downgrade:
+                               self._dynamic_config.myparams["complete"] = True
+                       else:
+                               # Skip complete graph mode, in order to avoid consuming
+                               # enough time to disturb users.
+                               return 1
 
                self._load_vdb()