Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 1446:4babaa52badf
abort on invalid pattern in matcher
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Tue, 25 Oct 2005 14:58:11 -0700 |
parents | b32b3509c7ab |
children | f4250806dbeb |
comparison
equal
deleted
inserted
replaced
1445:56281e086f38 | 1446:4babaa52badf |
---|---|
244 return '.*' + name | 244 return '.*' + name |
245 return head + globre(name, '', tail) | 245 return head + globre(name, '', tail) |
246 | 246 |
247 def matchfn(pats, tail): | 247 def matchfn(pats, tail): |
248 """build a matching function from a set of patterns""" | 248 """build a matching function from a set of patterns""" |
249 if pats: | 249 matches = [] |
250 pat = '(?:%s)' % '|'.join([regex(k, p, tail) for (k, p) in pats]) | 250 for k, p in pats: |
251 return re.compile(pat).match | 251 try: |
252 pat = '(?:%s)' % regex(k, p, tail) | |
253 matches.append(re.compile(pat).match) | |
254 except re.error, inst: | |
255 raise Abort("invalid pattern: %s:%s" % (k, p)) | |
256 | |
257 def buildfn(text): | |
258 for m in matches: | |
259 r = m(text) | |
260 if r: | |
261 return r | |
262 | |
263 return buildfn | |
252 | 264 |
253 def globprefix(pat): | 265 def globprefix(pat): |
254 '''return the non-glob prefix of a path, e.g. foo/* -> foo''' | 266 '''return the non-glob prefix of a path, e.g. foo/* -> foo''' |
255 root = [] | 267 root = [] |
256 for p in pat.split(os.sep): | 268 for p in pat.split(os.sep): |