From: Sebastian Luther <SebastianLuther@gmx.de>
Date: Sat, 7 Aug 2010 08:07:13 +0000 (+0200)
Subject: autounmask: Restart less often for use changes
X-Git-Tag: v2.2_rc68~363
X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=23225a062ac87a53c1a206a0c1978698458f7ce4;p=portage.git

autounmask: Restart less often for use changes
---

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index e0e215cf2..1d78a0cbd 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -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