autounmask: Restart less often for use changes
authorSebastian Luther <SebastianLuther@gmx.de>
Sat, 7 Aug 2010 08:07:13 +0000 (10:07 +0200)
committerZac Medico <zmedico@gentoo.org>
Sun, 8 Aug 2010 01:48:59 +0000 (18:48 -0700)
pym/_emerge/depgraph.py

index e0e215cf2f9a1b68aeba05b8a50a90558a76b7ca..1d78a0cbd43cb4e1ba599c33566a5f3f026bbfa6 100644 (file)
@@ -2627,19 +2627,37 @@ class depgraph(object):
                                        new_changes[flag] = False
                new_use.update(old_use.difference(target_use.keys()))
 
-               def want_restart_for_use_change(pkg):
+               def want_restart_for_use_change(pkg, new_use):
                        if pkg not in self._dynamic_config.digraph.nodes:
                                return False
-                       #TODO: We can be more clever here. No need to restart if 
-                       #       1) we don't have a parent that can't work with our 
-                       #               new use config
-                       #       and
-                       #       2) none of pkg's *DEPEND vars changed
-                       return True
+
+                       for key in "DEPEND", "RDEPEND", "PDEPEND", "LICENSE":
+                               dep = pkg.metadata[key]
+                               old_val = set(portage.dep.paren_normalize( \
+                                       portage.dep.use_reduce(portage.dep.paren_reduce(dep), pkg.use.enabled)))
+                               new_val = set(portage.dep.paren_normalize( \
+                                       portage.dep.use_reduce(portage.dep.paren_reduce(dep), new_use)))
+
+                               if old_val != new_val:
+                                       return True
+
+                       parent_atoms = self._dynamic_config._parent_atoms.get(pkg)
+                       if not parent_atoms:
+                               return False
+
+                       new_use, changes = self._dynamic_config._needed_use_config_changes.get(pkg)
+                       for ppkg, atom in parent_atoms:
+                               if not atom.use or \
+                                       not atom.use.required.intersection(changes.keys()):
+                                       continue
+                               else:
+                                       return True
+
+                       return False
 
                if new_changes != old_changes:
                        self._dynamic_config._needed_use_config_changes[pkg] = (new_use, new_changes)
-                       if want_restart_for_use_change(pkg):
+                       if want_restart_for_use_change(pkg, new_use):
                                self._dynamic_config._need_restart = True
                return new_use