Fix some poor installed/masked || choices.
authorZac Medico <zmedico@gentoo.org>
Tue, 18 Jan 2011 22:17:31 +0000 (14:17 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 18 Jan 2011 22:26:18 +0000 (14:26 -0800)
This will fix bug #351828. It's fallout from bug #350285.

pym/_emerge/depgraph.py
pym/portage/tests/resolver/test_simple.py

index ba06fbc0f2848a066c32d37c6083511693ba1179..1a203545f7ed4389e13b086c14a910c5a723f8ee 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
@@ -2914,14 +2914,16 @@ class depgraph(object):
                                                        continue
                                        reinstall_for_flags = None
 
-                                       if not pkg.installed or \
-                                               (matched_packages and not avoid_update):
+                                       if not pkg.installed or matched_packages:
                                                # Only enforce visibility on installed packages
                                                # if there is at least one other visible package
                                                # available. By filtering installed masked packages
                                                # here, packages that have been masked since they
                                                # were installed can be automatically downgraded
-                                               # to an unmasked version.
+                                               # to an unmasked version. NOTE: This code needs to
+                                               # be consistent with masking behavior inside
+                                               # _dep_check_composite_db, in order to prevent
+                                               # incorrect choices in || deps like bug #351828.
 
                                                if not self._pkg_visibility_check(pkg, \
                                                        allow_unstable_keywords=allow_unstable_keywords,
@@ -2933,15 +2935,8 @@ class depgraph(object):
                                                # version is masked by KEYWORDS, but never
                                                # reinstall the same exact version only due
                                                # to a KEYWORDS mask. See bug #252167.
-                                               if matched_packages:
 
-                                                       different_version = None
-                                                       for avail_pkg in matched_packages:
-                                                               if not portage.dep.cpvequal(
-                                                                       pkg.cpv, avail_pkg.cpv):
-                                                                       different_version = avail_pkg
-                                                                       break
-                                                       if different_version is not None:
+                                               if matched_packages:
                                                                # If the ebuild no longer exists or it's
                                                                # keywords have been dropped, reject built
                                                                # instances (installed or binary).
index 4e69d656493f093ed1039c098d6fa98dac19de04..c3ca9f4d553a15c174ff1ecd33f80cc90a755722 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -8,7 +8,7 @@ class SimpleResolverTestCase(TestCase):
 
        def testSimple(self):
                ebuilds = {
-                       "dev-libs/A-1": {}, 
+                       "dev-libs/A-1": { "KEYWORDS": "x86" }, 
                        "dev-libs/A-2": { "KEYWORDS": "~x86" },
                        "dev-libs/B-1.2": {},
 
@@ -18,17 +18,27 @@ class SimpleResolverTestCase(TestCase):
                        "app-misc/W-1": {},
                        }
                installed = {
+                       "dev-libs/A-1": {},
                        "dev-libs/B-1.1": {},
                        }
 
                test_cases = (
                        ResolverPlaygroundTestCase(["dev-libs/A"], success = True, mergelist = ["dev-libs/A-1"]),
                        ResolverPlaygroundTestCase(["=dev-libs/A-2"], success = False),
+
                        ResolverPlaygroundTestCase(
-                               ["dev-libs/B"],
+                               ["dev-libs/A"],
                                options = {"--noreplace": True},
                                success = True,
                                mergelist = []),
+
+                       # This triggers a replacement since the dev-libs/B-1.1 ebuild
+                       # is not available in the portage tree (see bug #351828).
+                       ResolverPlaygroundTestCase(
+                               ["dev-libs/B"],
+                               options = {"--noreplace": True},
+                               success = True,
+                               mergelist = ["dev-libs/B-1.2"]),
                        ResolverPlaygroundTestCase(
                                ["dev-libs/B"],
                                options = {"--update": True},