# HG changeset patch # User Benoit Boissinot # Date 1130277491 25200 # Node ID 4babaa52badf27dd8f22a330a3a989a40240b855 # Parent 56281e086f386f2ea812df5aa7ac13ead65e041c abort on invalid pattern in matcher diff -r 56281e086f38 -r 4babaa52badf mercurial/util.py --- a/mercurial/util.py Tue Oct 25 14:57:14 2005 -0700 +++ b/mercurial/util.py Tue Oct 25 14:58:11 2005 -0700 @@ -246,9 +246,21 @@ def matchfn(pats, tail): """build a matching function from a set of patterns""" - if pats: - pat = '(?:%s)' % '|'.join([regex(k, p, tail) for (k, p) in pats]) - return re.compile(pat).match + matches = [] + for k, p in pats: + try: + pat = '(?:%s)' % regex(k, p, tail) + matches.append(re.compile(pat).match) + except re.error, inst: + raise Abort("invalid pattern: %s:%s" % (k, p)) + + def buildfn(text): + for m in matches: + r = m(text) + if r: + return r + + return buildfn def globprefix(pat): '''return the non-glob prefix of a path, e.g. foo/* -> foo'''