##// END OF EJS Templates
Do not use 'glob' expansion by default on OS != 'nt'
Benoit Boissinot -
r1413:1c64c628 default
parent child Browse files
Show More
@@ -32,7 +32,7 b' def relpath(repo, args):'
32 return args
32 return args
33
33
34 def matchpats(repo, cwd, pats=[], opts={}, head=''):
34 def matchpats(repo, cwd, pats=[], opts={}, head=''):
35 return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'),
35 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
36 opts.get('exclude'), head)
36 opts.get('exclude'), head)
37
37
38 def makewalk(repo, pats, opts, head=''):
38 def makewalk(repo, pats, opts, head=''):
@@ -179,6 +179,16 b' def canonpath(root, cwd, myname):'
179 raise Abort('%s not under root' % myname)
179 raise Abort('%s not under root' % myname)
180
180
181 def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''):
181 def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''):
182 return _matcher(canonroot, cwd, names, inc, exc, head, 'glob')
183
184 def cmdmatcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''):
185 if os.name == 'nt':
186 dflt_pat = 'glob'
187 else:
188 dflt_pat = 'relpath'
189 return _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat)
190
191 def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat):
182 """build a function to match a set of file patterns
192 """build a function to match a set of file patterns
183
193
184 arguments:
194 arguments:
@@ -208,12 +218,15 b" def matcher(canonroot, cwd='', names=['."
208 make head regex a rooted bool
218 make head regex a rooted bool
209 """
219 """
210
220
211 def patkind(name):
221 def patkind(name, dflt_pat='glob'):
212 for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre':
222 for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre':
213 if name.startswith(prefix + ':'): return name.split(':', 1)
223 if name.startswith(prefix + ':'): return name.split(':', 1)
224 return dflt_pat, name
225
226 def contains_glob(name):
214 for c in name:
227 for c in name:
215 if c in _globchars: return 'glob', name
228 if c in _globchars: return True
216 return 'relpath', name
229 return False
217
230
218 def regex(kind, name, tail):
231 def regex(kind, name, tail):
219 '''convert a pattern into a regular expression'''
232 '''convert a pattern into a regular expression'''
@@ -241,14 +254,14 b" def matcher(canonroot, cwd='', names=['."
241 '''return the non-glob prefix of a path, e.g. foo/* -> foo'''
254 '''return the non-glob prefix of a path, e.g. foo/* -> foo'''
242 root = []
255 root = []
243 for p in pat.split(os.sep):
256 for p in pat.split(os.sep):
244 if patkind(p)[0] == 'glob': break
257 if contains_glob(p): break
245 root.append(p)
258 root.append(p)
246 return '/'.join(root)
259 return '/'.join(root)
247
260
248 pats = []
261 pats = []
249 files = []
262 files = []
250 roots = []
263 roots = []
251 for kind, name in map(patkind, names):
264 for kind, name in [patkind(p, dflt_pat) for p in names]:
252 if kind in ('glob', 'relpath'):
265 if kind in ('glob', 'relpath'):
253 name = canonpath(canonroot, cwd, name)
266 name = canonpath(canonroot, cwd, name)
254 if name == '':
267 if name == '':
@@ -30,7 +30,7 b' hg debugwalk ../beans'
30 hg debugwalk
30 hg debugwalk
31 cd ..
31 cd ..
32 hg debugwalk -Ibeans
32 hg debugwalk -Ibeans
33 hg debugwalk 'mammals/../beans/b*'
33 hg debugwalk 'glob:mammals/../beans/b*'
34 hg debugwalk '-X*/Procyonidae' mammals
34 hg debugwalk '-X*/Procyonidae' mammals
35 hg debugwalk path:mammals
35 hg debugwalk path:mammals
36 hg debugwalk ..
36 hg debugwalk ..
@@ -42,8 +42,8 b' hg debugwalk beans/../..'
42 hg debugwalk glob:\*
42 hg debugwalk glob:\*
43 hg debugwalk 're:.*[kb]$'
43 hg debugwalk 're:.*[kb]$'
44 hg debugwalk path:beans/black
44 hg debugwalk path:beans/black
45 hg debugwalk beans 'beans/*'
45 hg debugwalk beans 'glob:beans/*'
46 hg debugwalk 'j*'
46 hg debugwalk 'glob:j*'
47 hg debugwalk NOEXIST
47 hg debugwalk NOEXIST
48 mkfifo fifo
48 mkfifo fifo
49 hg debugwalk fifo
49 hg debugwalk fifo
General Comments 0
You need to be logged in to leave comments. Login now