depgraph: prefer highest priority repo more often
authorZac Medico <zmedico@gentoo.org>
Mon, 3 Jan 2011 07:13:56 +0000 (23:13 -0800)
committerZac Medico <zmedico@gentoo.org>
Mon, 3 Jan 2011 07:13:56 +0000 (23:13 -0800)
Prefer the highest priority repo, even when the ebuild from the higher
priority repo requires USE adjustments due to USE deps or REQUIRED_USE.
This will fix bug #350254.

pym/_emerge/Package.py
pym/_emerge/depgraph.py

index 0b3375edc661640c5d817e33a86280ad14796bb8..c80bad3acb0b0680ec426247ffe0acb145d78816 100644 (file)
@@ -351,6 +351,13 @@ class Package(Task):
        def repo(self):
                return self.metadata['repository']
 
+       @property
+       def repo_priority(self):
+               repo_info = self.root_config.settings.repositories.prepos.get(self.repo)
+               if repo_info is None:
+                       return None
+               return repo_info.priority
+
        @property
        def use(self):
                if self._use is None:
index badbb506dd612a3a50de8a5124bf3e7f348ca93d..f62af31b8d4ba24d577ad35d6c3fe2a82f5c417a 100644 (file)
@@ -2877,12 +2877,22 @@ class depgraph(object):
                                                # list only contains unbuilt ebuilds since USE can't
                                                # be changed for built packages.
                                                higher_version_rejected = False
+                                               repo_priority = pkg.repo_priority
                                                for rejected in packages_with_invalid_use_config:
                                                        if rejected.cp != pkg.cp:
                                                                continue
                                                        if rejected > pkg:
                                                                higher_version_rejected = True
                                                                break
+                                                       if portage.dep.cpvequal(rejected.cpv, pkg.cpv):
+                                                               # If version is identical then compare
+                                                               # repo priority (see bug #350254).
+                                                               rej_repo_priority = rejected.repo_priority
+                                                               if rej_repo_priority is not None and \
+                                                                       (repo_priority is None or
+                                                                       rej_repo_priority > repo_priority):
+                                                                       higher_version_rejected = True
+                                                                       break
                                                if higher_version_rejected:
                                                        continue