Fix --changed-use interaction with bug 297549.
authorZac Medico <zmedico@gentoo.org>
Fri, 20 Jan 2012 20:29:31 +0000 (12:29 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 20 Jan 2012 20:29:31 +0000 (12:29 -0800)
The automatic --binpkg-respect-use code (from bug #297549) was
inappropriately overriding --changed-use and triggering behavior like
--newuse, as reported here:

http://archives.gentoo.org/gentoo-dev/msg_6070ab87737d7e16a5cec2a72c9111fd.xml

pym/_emerge/depgraph.py

index 0c9e5f2ad8421a8faa7a836b4e8e0b9a256e87f7..6d0ba1ca2e20a3dfe19e9c7fff3688638f891411 100644 (file)
@@ -827,20 +827,28 @@ class depgraph(object):
                                        else:
                                                self._dynamic_config._slot_conflict_parent_atoms.add(parent_atom)
 
-       def _reinstall_for_flags(self, forced_flags,
+       def _reinstall_for_flags(self, pkg, forced_flags,
                orig_use, orig_iuse, cur_use, cur_iuse):
                """Return a set of flags that trigger reinstallation, or None if there
                are no such flags."""
-               if "--newuse" in self._frozen_config.myopts or \
-                       self._dynamic_config.myparams.get(
-                       "binpkg_respect_use") in ("y", "auto"):
+
+               # binpkg_respect_use: Behave like newuse by default. If newuse is
+               # False and changed_use is True, then behave like changed_use.
+               binpkg_respect_use = (pkg.built and
+                       self._dynamic_config.myparams.get("binpkg_respect_use")
+                       in ("y", "auto"))
+               newuse = "--newuse" in self._frozen_config.myopts
+               changed_use = "changed-use" == self._frozen_config.myopts.get("--reinstall")
+
+               if newuse or (binpkg_respect_use and not changed_use):
                        flags = set(orig_iuse.symmetric_difference(
                                cur_iuse).difference(forced_flags))
                        flags.update(orig_iuse.intersection(orig_use).symmetric_difference(
                                cur_iuse.intersection(cur_use)))
                        if flags:
                                return flags
-               elif "changed-use" == self._frozen_config.myopts.get("--reinstall"):
+
+               elif changed_use or binpkg_respect_use:
                        flags = orig_iuse.intersection(orig_use).symmetric_difference(
                                cur_iuse.intersection(cur_use))
                        if flags:
@@ -4039,8 +4047,8 @@ class depgraph(object):
                                                cur_iuse = iuses
                                                if myeb and not usepkgonly and not useoldpkg:
                                                        cur_iuse = myeb.iuse.all
-                                               reinstall_for_flags = self._reinstall_for_flags(forced_flags,
-                                                       old_use, iuses, now_use, cur_iuse)
+                                               reinstall_for_flags = self._reinstall_for_flags(pkg,
+                                                       forced_flags, old_use, iuses, now_use, cur_iuse)
                                                if reinstall_for_flags:
                                                        if not pkg.installed:
                                                                self._dynamic_config.ignored_binaries.setdefault(pkg, set()).update(reinstall_for_flags)
@@ -4060,7 +4068,7 @@ class depgraph(object):
                                                cur_use = self._pkg_use_enabled(pkg)
                                                cur_iuse = pkg.iuse.all
                                                reinstall_for_flags = \
-                                                       self._reinstall_for_flags(
+                                                       self._reinstall_for_flags(pkg,
                                                        forced_flags, old_use, old_iuse,
                                                        cur_use, cur_iuse)
                                                if reinstall_for_flags: