##// END OF EJS Templates
match: add an optional constructor parameter for a bad() override...
Matt Harbison -
r25464:504a1f29 default
parent child Browse files
Show More
@@ -78,7 +78,7 b' def _kindpatsalwaysmatch(kindpats):'
78 class match(object):
78 class match(object):
79 def __init__(self, root, cwd, patterns, include=[], exclude=[],
79 def __init__(self, root, cwd, patterns, include=[], exclude=[],
80 default='glob', exact=False, auditor=None, ctx=None,
80 default='glob', exact=False, auditor=None, ctx=None,
81 listsubrepos=False, warn=None):
81 listsubrepos=False, warn=None, badfn=None):
82 """build an object to match a set of file patterns
82 """build an object to match a set of file patterns
83
83
84 arguments:
84 arguments:
@@ -90,6 +90,7 b' class match(object):'
90 default - if a pattern in patterns has no explicit type, assume this one
90 default - if a pattern in patterns has no explicit type, assume this one
91 exact - patterns are actually filenames (include/exclude still apply)
91 exact - patterns are actually filenames (include/exclude still apply)
92 warn - optional function used for printing warnings
92 warn - optional function used for printing warnings
93 badfn - optional bad() callback for this matcher instead of the default
93
94
94 a pattern is one of:
95 a pattern is one of:
95 'glob:<glob>' - a glob relative to cwd
96 'glob:<glob>' - a glob relative to cwd
@@ -116,6 +117,9 b' class match(object):'
116 self._includedirs = set(['.'])
117 self._includedirs = set(['.'])
117 self._excluderoots = set()
118 self._excluderoots = set()
118
119
120 if badfn is not None:
121 self.bad = badfn
122
119 matchfns = []
123 matchfns = []
120 if include:
124 if include:
121 kindpats = self._normalize(include, 'glob', root, cwd, auditor)
125 kindpats = self._normalize(include, 'glob', root, cwd, auditor)
@@ -299,8 +303,8 b' class match(object):'
299 kindpats.append((kind, pat, ''))
303 kindpats.append((kind, pat, ''))
300 return kindpats
304 return kindpats
301
305
302 def exact(root, cwd, files):
306 def exact(root, cwd, files, badfn=None):
303 return match(root, cwd, files, exact=True)
307 return match(root, cwd, files, exact=True, badfn=badfn)
304
308
305 def always(root, cwd):
309 def always(root, cwd):
306 return match(root, cwd, [])
310 return match(root, cwd, [])
@@ -378,12 +382,12 b' class icasefsmatcher(match):'
378 """
382 """
379
383
380 def __init__(self, root, cwd, patterns, include, exclude, default, auditor,
384 def __init__(self, root, cwd, patterns, include, exclude, default, auditor,
381 ctx, listsubrepos=False):
385 ctx, listsubrepos=False, badfn=None):
382 init = super(icasefsmatcher, self).__init__
386 init = super(icasefsmatcher, self).__init__
383 self._dsnormalize = ctx.repo().dirstate.normalize
387 self._dsnormalize = ctx.repo().dirstate.normalize
384
388
385 init(root, cwd, patterns, include, exclude, default, auditor=auditor,
389 init(root, cwd, patterns, include, exclude, default, auditor=auditor,
386 ctx=ctx, listsubrepos=listsubrepos)
390 ctx=ctx, listsubrepos=listsubrepos, badfn=badfn)
387
391
388 # m.exact(file) must be based off of the actual user input, otherwise
392 # m.exact(file) must be based off of the actual user input, otherwise
389 # inexact case matches are treated as exact, and not noted without -v.
393 # inexact case matches are treated as exact, and not noted without -v.
General Comments 0
You need to be logged in to leave comments. Login now