Mercurial > hg > mercurial-crew-with-dirclash
diff mercurial/util.py @ 1270:fc3b41570082
Switch to new syntax for .hgignore files.
Here is the new syntax, in summary.
Trailing white space is dropped.
The escape character is "\".
Comments start with #.
Empty lines are skipped.
Lines can be of the following formats:
syntax: regexp # defaults following lines to non-rooted regexps
syntax: glob # defaults following lines to non-rooted globs
re:pattern # non-rooted regular expression
glob:pattern # non-rooted glob
pattern # pattern of the current default type
The default pattern type is regexp, which is completely backwards
compatible with the old hgignore syntax.
In the dirstate class, the ignore method has been reworked to be based
on the util.matcher function, by way of a new dirstate.hgignore
method.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sat, 17 Sep 2005 00:27:27 -0700 |
parents | 1945754e466b |
children | 1546c2aa6b30 |
line wrap: on
line diff
--- a/mercurial/util.py +++ b/mercurial/util.py @@ -122,7 +122,7 @@ def canonpath(root, cwd, myname): else: raise Abort('%s not under root' % myname) -def matcher(canonroot, cwd, names, inc, exc, head=''): +def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''): """build a function to match a set of file patterns arguments: @@ -134,11 +134,13 @@ def matcher(canonroot, cwd, names, inc, head - a regex to prepend to patterns to control whether a match is rooted a pattern is one of: - 're:<regex>' - 'glob:<shellglob>' - 'path:<explicit path>' + 'glob:<rooted glob>' + 're:<rooted regexp>' + 'path:<rooted path>' + 'relglob:<relative glob>' 'relpath:<relative path>' - '<relative path>' + 'relre:<relative regexp>' + '<rooted path or regexp>' returns: a 3-tuple containing @@ -151,8 +153,8 @@ def matcher(canonroot, cwd, names, inc, """ def patkind(name): - for prefix in 're:', 'glob:', 'path:', 'relpath:': - if name.startswith(prefix): return name.split(':', 1) + for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': + if name.startswith(prefix + ':'): return name.split(':', 1) for c in name: if c in _globchars: return 'glob', name return 'relpath', name @@ -163,8 +165,14 @@ def matcher(canonroot, cwd, names, inc, return name elif kind == 'path': return '^' + re.escape(name) + '(?:/|$)' + elif kind == 'relglob': + return head + globre(name, '(?:|.*/)', tail) elif kind == 'relpath': return head + re.escape(name) + tail + elif kind == 'relre': + if name.startswith('^'): + return name + return '.*' + name return head + globre(name, '', tail) def matchfn(pats, tail):