slot_conflict_handler: handle slot_abi
authorZac Medico <zmedico@gentoo.org>
Wed, 27 Jun 2012 17:19:36 +0000 (10:19 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 27 Jun 2012 17:19:36 +0000 (10:19 -0700)
We have to distinguish this from the "version" conflict, in order to
avoid invalid vercmp calls when there's not version.

pym/_emerge/resolver/slot_collision.py
pym/portage/tests/resolver/test_slot_collisions.py

index a1c87146c8a9a13f1c660844273599be1489c5bc..783a6483dfd91288514357d6f7155445e44f8966 100644 (file)
@@ -275,19 +275,29 @@ class slot_conflict_handler(object):
 
                                                        if not atom_without_use_set.findAtomForPackage(other_pkg, \
                                                                modified_use=_pkg_use_enabled(other_pkg)):
-                                                               #The version range does not match.
-                                                               sub_type = None
-                                                               if atom.operator in (">=", ">"):
-                                                                       sub_type = "ge"
-                                                               elif atom.operator in ("=", "~"):
-                                                                       sub_type = "eq"
-                                                               elif atom.operator in ("<=", "<"):
-                                                                       sub_type = "le"
-
-                                                               atoms = collision_reasons.get(("version", sub_type), set())
-                                                               atoms.add((ppkg, atom, other_pkg))
-                                                               num_all_specific_atoms += 1
-                                                               collision_reasons[("version", sub_type)] = atoms
+                                                               if atom.operator is not None:
+                                                                       # The version range does not match.
+                                                                       sub_type = None
+                                                                       if atom.operator in (">=", ">"):
+                                                                               sub_type = "ge"
+                                                                       elif atom.operator in ("=", "~"):
+                                                                               sub_type = "eq"
+                                                                       elif atom.operator in ("<=", "<"):
+                                                                               sub_type = "le"
+
+                                                                       key = ("version", sub_type)
+                                                                       atoms = collision_reasons.get(key, set())
+                                                                       atoms.add((ppkg, atom, other_pkg))
+                                                                       num_all_specific_atoms += 1
+                                                                       collision_reasons[key] = atoms
+                                                               else:
+                                                                       # The slot_abi does not match.
+                                                                       key = ("sub-slot", atom.slot_abi)
+                                                                       atoms = collision_reasons.get(key, set())
+                                                                       atoms.add((ppkg, atom, other_pkg))
+                                                                       num_all_specific_atoms += 1
+                                                                       collision_reasons[key] = atoms
+
                                                        elif not atom_set.findAtomForPackage(other_pkg, \
                                                                modified_use=_pkg_use_enabled(other_pkg)):
                                                                missing_iuse = other_pkg.iuse.get_missing_iuse(
@@ -333,6 +343,9 @@ class slot_conflict_handler(object):
                                                                else:
                                                                        best_matches[atom.cp] = (ppkg, atom)
                                                        selected_for_display.update(best_matches.values())
+                                               elif type == "sub-slot":
+                                                       for ppkg, atom, other_pkg in parents:
+                                                               selected_for_display.add((ppkg, atom))
                                                elif type == "use":
                                                        #Prefer atoms with unconditional use deps over, because it's
                                                        #not possible to change them on the parent, which means there
@@ -437,19 +450,22 @@ class slot_conflict_handler(object):
                                                        # Display the specific atom from SetArg or
                                                        # Package types.
                                                        version_violated = False
+                                                       sub_slot_violated = False
                                                        use = []
                                                        for (type, sub_type), parents in collision_reasons.items():
                                                                for x in parents:
                                                                        if parent == x[0] and atom == x[1]:
                                                                                if type == "version":
                                                                                        version_violated = True
+                                                                               elif type == "sub-slot":
+                                                                                       sub_slot_violated = True
                                                                                elif type == "use":
                                                                                        use.append(sub_type)
                                                                                break
 
                                                        atom_str = highlight_violations(atom.unevaluated_atom, version_violated, use)
 
-                                                       if version_violated:
+                                                       if version_violated or sub_slot_violated:
                                                                self.is_a_version_conflict = True
 
                                                        msg.append("%s required by %s" % (atom_str, parent))
index 4867cea0508adb56f7403661185d9c5133107c90..95d68fe040ad6e8d9e4aca46e43d958f5964f84e 100644 (file)
@@ -45,6 +45,9 @@ class SlotCollisionTestCase(TestCase):
                        "app-misc/C-1": { "DEPEND": "=app-misc/A-1[foo]", "EAPI": 2 },
                        "app-misc/E-1": { "RDEPEND": "dev-libs/E[foo?]", "IUSE": "foo", "EAPI": "2" },
                        "app-misc/F-1": { "RDEPEND": "=dev-libs/E-1", "IUSE": "foo", "EAPI": "2" },
+
+                       "dev-lang/perl-5.12": {"SLOT": "0/5.12", "EAPI": "4-slot-abi"},
+                       "dev-lang/perl-5.16": {"SLOT": "0/5.16", "EAPI": "4-slot-abi"},
                        }
                installed = {
                        "dev-libs/A-1": { "PDEPEND": "foo? ( dev-libs/B )", "IUSE": "foo", "USE": "foo" }, 
@@ -104,6 +107,15 @@ class SlotCollisionTestCase(TestCase):
                                slot_collision_solutions = []
                                ),
 
+                       # sub-slot
+                       ResolverPlaygroundTestCase(
+                               ["dev-lang/perl:0/5.12", "dev-lang/perl:0/5.16", "=dev-lang/perl-5.12*"],
+                               success = False,
+                               mergelist = ["dev-lang/perl-5.12", "dev-lang/perl-5.16"],
+                               ignore_mergelist_order = True,
+                               slot_collision_solutions = []
+                               ),
+
                        #Simple cases.
                        ResolverPlaygroundTestCase(
                                ["sci-libs/L", "sci-libs/M"],