Mercurial > hg
comparison mercurial/match.py @ 8572:dd46948a07fa
match: kill test in matchfn
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 24 May 2009 02:56:14 -0500 |
parents | 9f12e1a27a1b |
children | 62c996d543e6 |
comparison
equal
deleted
inserted
replaced
8571:9f12e1a27a1b | 8572:dd46948a07fa |
---|---|
173 return '.*' + name | 173 return '.*' + name |
174 return _globre(name, '', tail) | 174 return _globre(name, '', tail) |
175 | 175 |
176 def matchfn(pats, tail): | 176 def matchfn(pats, tail): |
177 """build a matching function from a set of patterns""" | 177 """build a matching function from a set of patterns""" |
178 if not pats: | |
179 return | |
180 try: | 178 try: |
181 pat = '(?:%s)' % '|'.join([regex(k, p, tail) for (k, p) in pats]) | 179 pat = '(?:%s)' % '|'.join([regex(k, p, tail) for (k, p) in pats]) |
182 if len(pat) > 20000: | 180 if len(pat) > 20000: |
183 raise OverflowError() | 181 raise OverflowError() |
184 return re.compile(pat).match | 182 return re.compile(pat).match |
231 roots.append('.') | 229 roots.append('.') |
232 return roots, pats, anypats | 230 return roots, pats, anypats |
233 | 231 |
234 roots, pats, anypats = normalizepats(names, dflt_pat) | 232 roots, pats, anypats = normalizepats(names, dflt_pat) |
235 | 233 |
236 patmatch = matchfn(pats, '$') | 234 if names: |
235 patmatch = matchfn(pats, '$') | |
237 if inc: | 236 if inc: |
238 dummy, inckinds, dummy = normalizepats(inc, 'glob') | 237 dummy, inckinds, dummy = normalizepats(inc, 'glob') |
239 incmatch = matchfn(inckinds, '(?:/|$)') | 238 incmatch = matchfn(inckinds, '(?:/|$)') |
240 if exc: | 239 if exc: |
241 dummy, exckinds, dummy = normalizepats(exc, 'glob') | 240 dummy, exckinds, dummy = normalizepats(exc, 'glob') |