util._matcher: fix handling of relglob: patterns

This commit is contained in:
Alexis S. L. Carvalho 2007-03-10 23:00:48 -03:00
parent c83e2fe93d
commit a2bea59405
3 changed files with 15 additions and 2 deletions

View File

@ -433,7 +433,7 @@ def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
elif kind == 'path':
return '^' + re.escape(name) + '(?:/|$)'
elif kind == 'relglob':
return head + globre(name, '(?:|.*/)', tail)
return head + globre(name, '(?:|.*/)', '(?:/|$)')
elif kind == 'relpath':
return head + re.escape(name) + tail
elif kind == 'relre':
@ -479,7 +479,9 @@ def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
name = canonpath(canonroot, cwd, name)
if name == '':
kind, name = 'glob', '**'
if kind in ('glob', 'path', 're'):
elif kind == 'relglob':
name = normpath(name)
if kind in ('glob', 'path', 're', 'relglob'):
pats.append((kind, name))
if kind == 'glob':
root = globprefix(name)
@ -487,6 +489,8 @@ def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src):
elif kind == 'relpath':
files.append((kind, name))
roots.append(name)
elif kind == 'relglob':
roots.append('.')
patmatch = matchfn(pats, '$') or always
filematch = matchfn(files, '(?:/|$)') or always

View File

@ -48,6 +48,8 @@ hg debugwalk beans/.hg
hg debugwalk glob:\*
hg debugwalk 're:.*[kb]$'
hg debugwalk path:beans/black
hg debugwalk relglob:Procyonidae
hg debugwalk relglob:Procyonidae/ fennel
hg debugwalk beans 'glob:beans/*'
hg debugwalk 'glob:mamm**'
hg debugwalk 'glob:mamm**' fennel

View File

@ -84,6 +84,13 @@ f fenugreek fenugreek
f glob:glob glob:glob
f mammals/skunk mammals/skunk
f beans/black beans/black
f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle
f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi
f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
f fennel fennel exact
f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle
f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi
f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
f beans/black beans/black
f beans/borlotti beans/borlotti
f beans/kidney beans/kidney