# HG changeset patch # User Benoit Boissinot # Date 1129705361 25200 # Node ID 1c64c628d15f31740a60ff427f7694bdb6b62f49 # Parent c1e0aebfabc0d82c66eec19e71c60fa937fa5a51 Do not use 'glob' expansion by default on OS != 'nt' diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -32,7 +32,7 @@ def relpath(repo, args): return args def matchpats(repo, cwd, pats=[], opts={}, head=''): - return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'), + return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'), opts.get('exclude'), head) def makewalk(repo, pats, opts, head=''): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -179,6 +179,16 @@ def canonpath(root, cwd, myname): raise Abort('%s not under root' % myname) def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''): + return _matcher(canonroot, cwd, names, inc, exc, head, 'glob') + +def cmdmatcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''): + if os.name == 'nt': + dflt_pat = 'glob' + else: + dflt_pat = 'relpath' + return _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat) + +def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat): """build a function to match a set of file patterns arguments: @@ -208,12 +218,15 @@ def matcher(canonroot, cwd='', names=['. make head regex a rooted bool """ - def patkind(name): + def patkind(name, dflt_pat='glob'): for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': if name.startswith(prefix + ':'): return name.split(':', 1) + return dflt_pat, name + + def contains_glob(name): for c in name: - if c in _globchars: return 'glob', name - return 'relpath', name + if c in _globchars: return True + return False def regex(kind, name, tail): '''convert a pattern into a regular expression''' @@ -241,14 +254,14 @@ def matcher(canonroot, cwd='', names=['. '''return the non-glob prefix of a path, e.g. foo/* -> foo''' root = [] for p in pat.split(os.sep): - if patkind(p)[0] == 'glob': break + if contains_glob(p): break root.append(p) return '/'.join(root) pats = [] files = [] roots = [] - for kind, name in map(patkind, names): + for kind, name in [patkind(p, dflt_pat) for p in names]: if kind in ('glob', 'relpath'): name = canonpath(canonroot, cwd, name) if name == '': diff --git a/tests/test-walk b/tests/test-walk --- a/tests/test-walk +++ b/tests/test-walk @@ -30,7 +30,7 @@ hg debugwalk ../beans hg debugwalk cd .. hg debugwalk -Ibeans -hg debugwalk 'mammals/../beans/b*' +hg debugwalk 'glob:mammals/../beans/b*' hg debugwalk '-X*/Procyonidae' mammals hg debugwalk path:mammals hg debugwalk .. @@ -42,8 +42,8 @@ hg debugwalk beans/../.. hg debugwalk glob:\* hg debugwalk 're:.*[kb]$' hg debugwalk path:beans/black -hg debugwalk beans 'beans/*' -hg debugwalk 'j*' +hg debugwalk beans 'glob:beans/*' +hg debugwalk 'glob:j*' hg debugwalk NOEXIST mkfifo fifo hg debugwalk fifo