# HG changeset patch # User Matt Harbison # Date 1433544993 14400 # Node ID 504a1f295677b311a774e37f918bd5efafe2b742 # Parent 03af5c2ddf75f3eb08d1974b21532ac538da279e match: add an optional constructor parameter for a bad() override This will be used to eliminate monkey patching of new matcher instances that weren't removed in 5984dd42e140::1a95c57959f6. diff -r 03af5c2ddf75 -r 504a1f295677 mercurial/match.py --- a/mercurial/match.py Sun Jun 07 09:30:15 2015 +0900 +++ b/mercurial/match.py Fri Jun 05 18:56:33 2015 -0400 @@ -78,7 +78,7 @@ class match(object): def __init__(self, root, cwd, patterns, include=[], exclude=[], default='glob', exact=False, auditor=None, ctx=None, - listsubrepos=False, warn=None): + listsubrepos=False, warn=None, badfn=None): """build an object to match a set of file patterns arguments: @@ -90,6 +90,7 @@ default - if a pattern in patterns has no explicit type, assume this one exact - patterns are actually filenames (include/exclude still apply) warn - optional function used for printing warnings + badfn - optional bad() callback for this matcher instead of the default a pattern is one of: 'glob:' - a glob relative to cwd @@ -116,6 +117,9 @@ self._includedirs = set(['.']) self._excluderoots = set() + if badfn is not None: + self.bad = badfn + matchfns = [] if include: kindpats = self._normalize(include, 'glob', root, cwd, auditor) @@ -299,8 +303,8 @@ kindpats.append((kind, pat, '')) return kindpats -def exact(root, cwd, files): - return match(root, cwd, files, exact=True) +def exact(root, cwd, files, badfn=None): + return match(root, cwd, files, exact=True, badfn=badfn) def always(root, cwd): return match(root, cwd, []) @@ -378,12 +382,12 @@ """ def __init__(self, root, cwd, patterns, include, exclude, default, auditor, - ctx, listsubrepos=False): + ctx, listsubrepos=False, badfn=None): init = super(icasefsmatcher, self).__init__ self._dsnormalize = ctx.repo().dirstate.normalize init(root, cwd, patterns, include, exclude, default, auditor=auditor, - ctx=ctx, listsubrepos=listsubrepos) + ctx=ctx, listsubrepos=listsubrepos, badfn=badfn) # m.exact(file) must be based off of the actual user input, otherwise # inexact case matches are treated as exact, and not noted without -v.