comparison mercurial/match.py @ 8578:8388ef8d21cd

match: tweak some names
author Matt Mackall <mpm@selenic.com>
date Sun, 24 May 2009 02:56:14 -0500
parents c7bab7fede4c
children aff7f83c365b
comparison
equal deleted inserted replaced
8577:c7bab7fede4c 8578:8388ef8d21cd
164 if '[' in p or '{' in p or '*' in p or '?' in p: 164 if '[' in p or '{' in p or '*' in p or '?' in p:
165 break 165 break
166 root.append(p) 166 root.append(p)
167 return '/'.join(root) or '.' 167 return '/'.join(root) or '.'
168 168
169 def _normalizepats(names, default, canonroot, cwd): 169 def _normalize(names, default, root, cwd):
170 pats = [] 170 pats = []
171 for kind, name in [_patsplit(p, default) for p in names]: 171 for kind, name in [_patsplit(p, default) for p in names]:
172 if kind in ('glob', 'relpath'): 172 if kind in ('glob', 'relpath'):
173 name = util.canonpath(canonroot, cwd, name) 173 name = util.canonpath(root, cwd, name)
174 elif kind in ('relglob', 'path'): 174 elif kind in ('relglob', 'path'):
175 name = util.normpath(name) 175 name = util.normpath(name)
176 176
177 pats.append((kind, name)) 177 pats.append((kind, name))
178 return pats 178 return pats
224 224
225 roots = [] 225 roots = []
226 anypats = bool(inc or exc) 226 anypats = bool(inc or exc)
227 227
228 if names: 228 if names:
229 pats = _normalizepats(names, dflt_pat, root, cwd) 229 pats = _normalize(names, dflt_pat, root, cwd)
230 roots = _roots(pats) 230 roots = _roots(pats)
231 anypats = anypats or _anypats(pats) 231 anypats = anypats or _anypats(pats)
232 patmatch = _matchfn(pats, '$') 232 patmatch = _matchfn(pats, '$')
233 if inc: 233 if inc:
234 incmatch = _matchfn(_normalizepats(inc, 'glob', root, cwd), '(?:/|$)') 234 incmatch = _matchfn(_normalize(inc, 'glob', root, cwd), '(?:/|$)')
235 if exc: 235 if exc:
236 excmatch = _matchfn(_normalizepats(exc, 'glob', root, cwd), '(?:/|$)') 236 excmatch = _matchfn(_normalize(exc, 'glob', root, cwd), '(?:/|$)')
237 237
238 if names: 238 if names:
239 if inc: 239 if inc:
240 if exc: 240 if exc:
241 m = lambda f: incmatch(f) and not excmatch(f) and patmatch(f) 241 m = lambda f: incmatch(f) and not excmatch(f) and patmatch(f)