depgraph: don't reinstall for changed repo
authorZac Medico <zmedico@gentoo.org>
Wed, 19 Jan 2011 01:22:20 +0000 (17:22 -0800)
committerZac Medico <zmedico@gentoo.org>
Wed, 19 Jan 2011 01:22:20 +0000 (17:22 -0800)
pym/_emerge/depgraph.py
pym/portage/tests/resolver/test_multirepo.py

index 7375476263e6f56499709df3e752f6d401c698b6..c73381a82e2f9c2ec1e05d42cb6a5bcaae83b067 100644 (file)
@@ -2991,7 +2991,16 @@ class depgraph(object):
                                                                                pkg_eb = self._pkg(
                                                                                        pkg.cpv, "ebuild", root_config, myrepo=pkg.repo)
                                                                        except portage.exception.PackageNotFound:
-                                                                               continue
+                                                                               pkg_eb_visible = False
+                                                                               for pkg_eb in self._iter_match_pkgs(pkg.root_config,
+                                                                                       "ebuild", Atom("=%s" % (pkg.cpv,))):
+                                                                                       if self._pkg_visibility_check(pkg_eb, \
+                                                                                               allow_unstable_keywords=allow_unstable_keywords,
+                                                                                               allow_license_changes=allow_license_changes):
+                                                                                               pkg_eb_visible = True
+                                                                                               break
+                                                                               if not pkg_eb_visible:
+                                                                                       continue
                                                                        else:
                                                                                if not self._pkg_visibility_check(pkg_eb, \
                                                                                        allow_unstable_keywords=allow_unstable_keywords,
@@ -5499,7 +5508,15 @@ class _dep_check_composite_db(dbapi):
                                                        pkg.cpv, "ebuild", pkg.root_config,
                                                        myrepo=pkg.repo)
                                        except portage.exception.PackageNotFound:
-                                               return False
+                                               pkg_eb_visible = False
+                                               for pkg_eb in self._depgraph._iter_match_pkgs(
+                                                       pkg.root_config, "ebuild",
+                                                       Atom("=%s" % (pkg.cpv,))):
+                                                       if self._depgraph._pkg_visibility_check(pkg_eb):
+                                                               pkg_eb_visible = True
+                                                               break
+                                               if not pkg_eb_visible:
+                                                       return False
                                        else:
                                                if not self._depgraph._pkg_visibility_check(pkg_eb):
                                                        return False
index 542bdd5949c4c44c8a38f9bdf1cbe0a050679431..a4b905e698d594e537a6ba170e9a9ad300480409 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
@@ -129,14 +129,13 @@ class MultirepoTestCase(TestCase):
                                mergelist = ["dev-libs/F-1::repo1"]),
 
                        # Dependency on installed dev-libs/C-2 ebuild for which ebuild is
-                       # not available from the same repo should not unnecessarily pull
-                       # in a different slot. It should just pull in the same slot from
-                       # a different repo (bug #351828).
+                       # not available from the same repo should not unnecessarily
+                       # reinstall the same version from a different repo.
                        ResolverPlaygroundTestCase(
                                ["dev-libs/H"],
                                options = {"--update": True, "--deep": True},
                                success = True,
-                               mergelist = ["dev-libs/I-2"]),
+                               mergelist = []),
 
                        # Check interaction between repo priority and unsatisfied
                        # REQUIRED_USE, for bug #350254.
@@ -180,6 +179,10 @@ class MultirepoTestCase(TestCase):
                        "dev-libs/E-1::repo1": { },
                        "dev-libs/H-1": { },
                        "dev-libs/H-1::repo1": { },
+                       "dev-libs/I-1::repo2": { "SLOT" : "1"},
+                       "dev-libs/I-2::repo2": { "SLOT" : "2"},
+                       "dev-libs/J-1": {       "KEYWORDS": "x86", "EAPI" : "3",
+                                                               "RDEPEND" : "|| ( dev-libs/I:2 dev-libs/I:1 )" },
 
                        #package.properties
                        "dev-libs/F-1": { "PROPERTIES": "bar"},
@@ -193,6 +196,11 @@ class MultirepoTestCase(TestCase):
                        "dev-libs/Z-1::repo3": { },
                        }
 
+               installed = {
+                       "dev-libs/J-1": { "RDEPEND" : "|| ( dev-libs/I:2 dev-libs/I:1 )"},
+                       "dev-libs/I-2::repo1": {"SLOT" : "2"},
+                       }
+
                user_config = {
                        "package.use":
                                (
@@ -210,6 +218,7 @@ class MultirepoTestCase(TestCase):
                                (
                                        "dev-libs/E::repo1",
                                        "dev-libs/H",
+                                       "dev-libs/I::repo1",
                                        #needed for package.unmask test
                                        "dev-libs/G",
                                        #wildcard test
@@ -263,6 +272,16 @@ class MultirepoTestCase(TestCase):
                                check_repo_names = True,
                                mergelist = ["dev-libs/E-1"]),
 
+                       # Dependency on installed dev-libs/C-2 ebuild for which ebuild is
+                       # masked from the same repo should not unnecessarily pull
+                       # in a different slot. It should just pull in the same slot from
+                       # a different repo (bug #351828).
+                       ResolverPlaygroundTestCase(
+                               ["dev-libs/J"],
+                               options = {"--update": True, "--deep": True},
+                               success = True,
+                               mergelist = ["dev-libs/I-2"]),
+
                        #package.properties test
                        ResolverPlaygroundTestCase(
                                ["dev-libs/F"],
@@ -286,7 +305,8 @@ class MultirepoTestCase(TestCase):
                                success = False),
                        )
 
-               playground = ResolverPlayground(ebuilds=ebuilds, user_config=user_config)
+               playground = ResolverPlayground(ebuilds=ebuilds,
+                       installed=installed, user_config=user_config)
                try:
                        for test_case in test_cases:
                                playground.run_TestCase(test_case)