Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 1563:cc2a2e12f4ad
export patkind() from util
author | Robin Farine <robin.farine@terminus.org> |
---|---|
date | Thu, 01 Dec 2005 10:48:22 -0600 |
parents | 487e256ad545 |
children | 8befbb4e30b2 |
comparison
equal
deleted
inserted
replaced
1562:2f97af0b522c | 1563:cc2a2e12f4ad |
---|---|
103 class Abort(Exception): | 103 class Abort(Exception): |
104 """Raised if a command needs to print an error and exit.""" | 104 """Raised if a command needs to print an error and exit.""" |
105 | 105 |
106 def always(fn): return True | 106 def always(fn): return True |
107 def never(fn): return False | 107 def never(fn): return False |
108 | |
109 def patkind(name, dflt_pat='glob'): | |
110 """Split a string into an optional pattern kind prefix and the | |
111 actual pattern.""" | |
112 for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': | |
113 if name.startswith(prefix + ':'): return name.split(':', 1) | |
114 return dflt_pat, name | |
108 | 115 |
109 def globre(pat, head='^', tail='$'): | 116 def globre(pat, head='^', tail='$'): |
110 "convert a glob pattern into a regexp" | 117 "convert a glob pattern into a regexp" |
111 i, n = 0, len(pat) | 118 i, n = 0, len(pat) |
112 res = '' | 119 res = '' |
218 | 225 |
219 todo: | 226 todo: |
220 make head regex a rooted bool | 227 make head regex a rooted bool |
221 """ | 228 """ |
222 | 229 |
223 def patkind(name, dflt_pat='glob'): | |
224 for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': | |
225 if name.startswith(prefix + ':'): return name.split(':', 1) | |
226 return dflt_pat, name | |
227 | |
228 def contains_glob(name): | 230 def contains_glob(name): |
229 for c in name: | 231 for c in name: |
230 if c in _globchars: return True | 232 if c in _globchars: return True |
231 return False | 233 return False |
232 | 234 |