##// END OF EJS Templates
matcher: make e.g. 'relpath:.' lead to fast paths...
Martin von Zweigbergk -
r24447:d44d53bc default
parent child Browse files
Show More
@@ -34,6 +34,15 b' def _expandsets(kindpats, ctx):'
34 other.append((kind, pat))
34 other.append((kind, pat))
35 return fset, other
35 return fset, other
36
36
37 def _kindpatsalwaysmatch(kindpats):
38 """"Checks whether the kindspats match everything, as e.g.
39 'relpath:.' does.
40 """
41 for kind, pat in kindpats:
42 if pat != '' or kind not in ['relpath', 'glob']:
43 return False
44 return True
45
37 class match(object):
46 class match(object):
38 def __init__(self, root, cwd, patterns, include=[], exclude=[],
47 def __init__(self, root, cwd, patterns, include=[], exclude=[],
39 default='glob', exact=False, auditor=None, ctx=None):
48 default='glob', exact=False, auditor=None, ctx=None):
@@ -84,10 +93,11 b' class match(object):'
84 matchfns.append(self.exact)
93 matchfns.append(self.exact)
85 elif patterns:
94 elif patterns:
86 kindpats = _normalize(patterns, default, root, cwd, auditor)
95 kindpats = _normalize(patterns, default, root, cwd, auditor)
87 self._files = _roots(kindpats)
96 if not _kindpatsalwaysmatch(kindpats):
88 self._anypats = self._anypats or _anypats(kindpats)
97 self._files = _roots(kindpats)
89 self.patternspat, pm = _buildmatch(ctx, kindpats, '$')
98 self._anypats = self._anypats or _anypats(kindpats)
90 matchfns.append(pm)
99 self.patternspat, pm = _buildmatch(ctx, kindpats, '$')
100 matchfns.append(pm)
91
101
92 if not matchfns:
102 if not matchfns:
93 m = util.always
103 m = util.always
@@ -725,6 +725,8 b' def matchandpats(ctx, pats=[], opts={}, '
725 def badfn(f, msg):
725 def badfn(f, msg):
726 ctx.repo().ui.warn("%s: %s\n" % (m.rel(f), msg))
726 ctx.repo().ui.warn("%s: %s\n" % (m.rel(f), msg))
727 m.bad = badfn
727 m.bad = badfn
728 if m.always():
729 pats = []
728 return m, pats
730 return m, pats
729
731
730 def match(ctx, pats=[], opts={}, globbed=False, default='relpath'):
732 def match(ctx, pats=[], opts={}, globbed=False, default='relpath'):
General Comments 0
You need to be logged in to leave comments. Login now