##// END OF EJS Templates
match: make subinclude construction lazy...
Durham Goode -
r32132:6dea1701 default
parent child Browse files
Show More
@@ -52,7 +52,7 b' def _expandsets(kindpats, ctx, listsubre'
52 return fset, other
52 return fset, other
53
53
54 def _expandsubinclude(kindpats, root):
54 def _expandsubinclude(kindpats, root):
55 '''Returns the list of subinclude matchers and the kindpats without the
55 '''Returns the list of subinclude matcher args and the kindpats without the
56 subincludes in it.'''
56 subincludes in it.'''
57 relmatchers = []
57 relmatchers = []
58 other = []
58 other = []
@@ -64,12 +64,12 b' def _expandsubinclude(kindpats, root):'
64 path = pathutil.join(sourceroot, pat)
64 path = pathutil.join(sourceroot, pat)
65
65
66 newroot = pathutil.dirname(path)
66 newroot = pathutil.dirname(path)
67 relmatcher = match(newroot, '', [], ['include:%s' % path])
67 matcherargs = (newroot, '', [], ['include:%s' % path])
68
68
69 prefix = pathutil.canonpath(root, root, newroot)
69 prefix = pathutil.canonpath(root, root, newroot)
70 if prefix:
70 if prefix:
71 prefix += '/'
71 prefix += '/'
72 relmatchers.append((prefix, relmatcher))
72 relmatchers.append((prefix, matcherargs))
73 else:
73 else:
74 other.append((kind, pat, source))
74 other.append((kind, pat, source))
75
75
@@ -584,10 +584,17 b' def _buildmatch(ctx, kindpats, globsuffi'
584
584
585 subincludes, kindpats = _expandsubinclude(kindpats, root)
585 subincludes, kindpats = _expandsubinclude(kindpats, root)
586 if subincludes:
586 if subincludes:
587 submatchers = {}
587 def matchsubinclude(f):
588 def matchsubinclude(f):
588 for prefix, mf in subincludes:
589 for prefix, matcherargs in subincludes:
589 if f.startswith(prefix) and mf(f[len(prefix):]):
590 if f.startswith(prefix):
590 return True
591 mf = submatchers.get(prefix)
592 if mf is None:
593 mf = match(*matcherargs)
594 submatchers[prefix] = mf
595
596 if mf(f[len(prefix):]):
597 return True
591 return False
598 return False
592 matchfuncs.append(matchsubinclude)
599 matchfuncs.append(matchsubinclude)
593
600
General Comments 0
You need to be logged in to leave comments. Login now