Mercurial > public > mercurial-scm > hg
diff mercurial/match.py @ 13218:1f4721de2ca9
match: support reading pattern lists from files
author | Steve Borho <steve@borho.org> |
---|---|
date | Thu, 23 Dec 2010 15:12:24 -0600 |
parents | 83aaeba32b88 |
children | 3e66eec9a814 |
line wrap: on
line diff
--- a/mercurial/match.py Thu Dec 30 23:36:50 2010 -0600 +++ b/mercurial/match.py Thu Dec 23 15:12:24 2010 -0600 @@ -161,7 +161,8 @@ actual pattern.""" if ':' in pat: kind, val = pat.split(':', 1) - if kind in ('re', 'glob', 'path', 'relglob', 'relpath', 'relre'): + if kind in ('re', 'glob', 'path', 'relglob', 'relpath', 'relre', + 'listfile', 'listfile0'): return kind, val return default, pat @@ -270,6 +271,15 @@ name = util.canonpath(root, cwd, name, auditor) elif kind in ('relglob', 'path'): name = util.normpath(name) + elif kind in ('listfile', 'listfile0'): + delimiter = kind == 'listfile0' and '\0' or '\n' + try: + files = open(name, 'r').read().split(delimiter) + files = [f for f in files if f] + except EnvironmentError: + raise util.Abort(_("unable to read file list (%s)") % name) + pats += _normalize(files, default, root, cwd, auditor) + continue pats.append((kind, name)) return pats