Merged from trunk 5261:5264
authorFabian Groffen <grobian@gentoo.org>
Sun, 10 Dec 2006 21:53:39 +0000 (21:53 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 10 Dec 2006 21:53:39 +0000 (21:53 -0000)
Don't collapse the tuple into a hash, since dict can use __eq__ to avoid
problems with hash collisions.  Thanks to Brian Harring for reporting.

For bug #157734, fix repoman isvalidatom() checks.  Thanks to Brian
Harring for the patch.

Add an allow_blockers parameter to isvalidatom so that the behavior is
optional.  Thanks to Brian Harring for the suggestion.

svn path=/main/branches/prefix/; revision=5265

bin/repoman
pym/portage_dep.py

index 7a258e0a01aa0c639f0e5f8956c55d555331f321..0cf726abc3e580ccba13a2f6444bd12c00c1ca29 100755 (executable)
@@ -1221,7 +1221,7 @@ for x in scanlist:
                                        if token in operator_tokens or \
                                                token.endswith("?"):
                                                continue
-                                       if not portage.isvalidatom(token) or \
+                                       if not portage.isvalidatom(token, allow_blockers=True) or \
                                                ":" in token and myaux["EAPI"] == "0":
                                                badsyntax.append("'%s' not a valid atom" % token)
 
index c13d6ec5d8df5c02bd61c88285c2a89ffdaa65f9..d5c60e658018c6d380757a1225f3ec190c5e849f 100644 (file)
@@ -313,7 +313,7 @@ def dep_getslot(mydep):
 
 _invalid_atom_chars_regexp = re.compile("[()|?]")
 
-def isvalidatom(atom):
+def isvalidatom(atom, allow_blockers=False):
        """
        Check to see if a depend atom is valid
 
@@ -333,6 +333,8 @@ def isvalidatom(atom):
        global _invalid_atom_chars_regexp
        if _invalid_atom_chars_regexp.search(atom):
                return 0
+       if allow_blockers and atom.startswith("!"):
+               atom = atom[1:]
        mycpv_cps = catpkgsplit(dep_getcpv(atom))
        operator = get_operator(atom)
        if operator:
@@ -501,8 +503,8 @@ def match_from_list(mydep, candidate_list):
        """
 
        global _match_from_list_cache
-       mylist = _match_from_list_cache.get(
-               hash((mydep, tuple(candidate_list))), None)
+       cache_key = (mydep, tuple(candidate_list))
+       mylist = _match_from_list_cache.get(cache_key, None)
        if mylist is not None:
                return mylist[:]
 
@@ -601,5 +603,5 @@ def match_from_list(mydep, candidate_list):
        else:
                raise KeyError("Unknown operator: %s" % mydep)
 
-       _match_from_list_cache[hash((mydep, tuple(candidate_list)))] = mylist
+       _match_from_list_cache[cache_key] = mylist
        return mylist