##// END OF EJS Templates
remove unused "head" hack from util._matcher
Alexis S. L. Carvalho -
r4197:492d0d5b default
parent child Browse files
Show More
@@ -127,16 +127,16 b' def make_file(repo, pat, node=None,'
127 pathname),
127 pathname),
128 mode)
128 mode)
129
129
130 def matchpats(repo, pats=[], opts={}, head='', globbed=False, default=None):
130 def matchpats(repo, pats=[], opts={}, globbed=False, default=None):
131 cwd = repo.getcwd()
131 cwd = repo.getcwd()
132 return util.cmdmatcher(repo.root, cwd, pats or [], opts.get('include'),
132 return util.cmdmatcher(repo.root, cwd, pats or [], opts.get('include'),
133 opts.get('exclude'), head, globbed=globbed,
133 opts.get('exclude'), globbed=globbed,
134 default=default)
134 default=default)
135
135
136 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None,
136 def walk(repo, pats=[], opts={}, node=None, badmatch=None, globbed=False,
137 globbed=False, default=None):
137 default=None):
138 files, matchfn, anypats = matchpats(repo, pats, opts, head,
138 files, matchfn, anypats = matchpats(repo, pats, opts, globbed=globbed,
139 globbed=globbed, default=default)
139 default=default)
140 exact = dict.fromkeys(files)
140 exact = dict.fromkeys(files)
141 for src, fn in repo.walk(node=node, files=files, match=matchfn,
141 for src, fn in repo.walk(node=node, files=files, match=matchfn,
142 badmatch=badmatch):
142 badmatch=badmatch):
@@ -378,17 +378,17 b' def canonpath(root, cwd, myname):'
378
378
379 raise Abort('%s not under root' % myname)
379 raise Abort('%s not under root' % myname)
380
380
381 def matcher(canonroot, cwd='', names=[], inc=[], exc=[], head='', src=None):
381 def matcher(canonroot, cwd='', names=[], inc=[], exc=[], src=None):
382 return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src)
382 return _matcher(canonroot, cwd, names, inc, exc, 'glob', src)
383
383
384 def cmdmatcher(canonroot, cwd='', names=[], inc=[], exc=[], head='',
384 def cmdmatcher(canonroot, cwd='', names=[], inc=[], exc=[], src=None,
385 src=None, globbed=False, default=None):
385 globbed=False, default=None):
386 default = default or 'relpath'
386 default = default or 'relpath'
387 if default == 'relpath' and not globbed:
387 if default == 'relpath' and not globbed:
388 names = expand_glob(names)
388 names = expand_glob(names)
389 return _matcher(canonroot, cwd, names, inc, exc, head, default, src)
389 return _matcher(canonroot, cwd, names, inc, exc, default, src)
390
390
391 def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
391 def _matcher(canonroot, cwd, names, inc, exc, dflt_pat, src):
392 """build a function to match a set of file patterns
392 """build a function to match a set of file patterns
393
393
394 arguments:
394 arguments:
@@ -397,7 +397,6 b' def _matcher(canonroot, cwd, names, inc,'
397 names - patterns to find
397 names - patterns to find
398 inc - patterns to include
398 inc - patterns to include
399 exc - patterns to exclude
399 exc - patterns to exclude
400 head - a regex to prepend to patterns to control whether a match is rooted
401 dflt_pat - if a pattern in names has no explicit type, assume this one
400 dflt_pat - if a pattern in names has no explicit type, assume this one
402 src - where these patterns came from (e.g. .hgignore)
401 src - where these patterns came from (e.g. .hgignore)
403
402
@@ -417,9 +416,6 b' def _matcher(canonroot, cwd, names, inc,'
417 includes the initial part of glob: patterns that has no glob characters
416 includes the initial part of glob: patterns that has no glob characters
418 - a bool match(filename) function
417 - a bool match(filename) function
419 - a bool indicating if any patterns were passed in
418 - a bool indicating if any patterns were passed in
420
421 todo:
422 make head regex a rooted bool
423 """
419 """
424
420
425 def contains_glob(name):
421 def contains_glob(name):
@@ -436,14 +432,14 b' def _matcher(canonroot, cwd, names, inc,'
436 elif kind == 'path':
432 elif kind == 'path':
437 return '^' + re.escape(name) + '(?:/|$)'
433 return '^' + re.escape(name) + '(?:/|$)'
438 elif kind == 'relglob':
434 elif kind == 'relglob':
439 return head + globre(name, '(?:|.*/)', '(?:/|$)')
435 return globre(name, '(?:|.*/)', '(?:/|$)')
440 elif kind == 'relpath':
436 elif kind == 'relpath':
441 return head + re.escape(name) + '(?:/|$)'
437 return re.escape(name) + '(?:/|$)'
442 elif kind == 'relre':
438 elif kind == 'relre':
443 if name.startswith('^'):
439 if name.startswith('^'):
444 return name
440 return name
445 return '.*' + name
441 return '.*' + name
446 return head + globre(name, '', tail)
442 return globre(name, '', tail)
447
443
448 def matchfn(pats, tail):
444 def matchfn(pats, tail):
449 """build a matching function from a set of patterns"""
445 """build a matching function from a set of patterns"""
General Comments 0
You need to be logged in to leave comments. Login now