From ec45787a3b1b48a5c137a2643b3e3029cacbf80b Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sun, 10 Dec 2006 21:53:39 +0000 Subject: [PATCH] Merged from trunk 5261:5264 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 | 2 +- pym/portage_dep.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/repoman b/bin/repoman index 7a258e0a0..0cf726abc 100755 --- a/bin/repoman +++ b/bin/repoman @@ -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) diff --git a/pym/portage_dep.py b/pym/portage_dep.py index c13d6ec5d..d5c60e658 100644 --- a/pym/portage_dep.py +++ b/pym/portage_dep.py @@ -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 -- 2.26.2