##// 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 52 return fset, other
53 53
54 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 56 subincludes in it.'''
57 57 relmatchers = []
58 58 other = []
@@ -64,12 +64,12 b' def _expandsubinclude(kindpats, root):'
64 64 path = pathutil.join(sourceroot, pat)
65 65
66 66 newroot = pathutil.dirname(path)
67 relmatcher = match(newroot, '', [], ['include:%s' % path])
67 matcherargs = (newroot, '', [], ['include:%s' % path])
68 68
69 69 prefix = pathutil.canonpath(root, root, newroot)
70 70 if prefix:
71 71 prefix += '/'
72 relmatchers.append((prefix, relmatcher))
72 relmatchers.append((prefix, matcherargs))
73 73 else:
74 74 other.append((kind, pat, source))
75 75
@@ -584,10 +584,17 b' def _buildmatch(ctx, kindpats, globsuffi'
584 584
585 585 subincludes, kindpats = _expandsubinclude(kindpats, root)
586 586 if subincludes:
587 submatchers = {}
587 588 def matchsubinclude(f):
588 for prefix, mf in subincludes:
589 if f.startswith(prefix) and mf(f[len(prefix):]):
590 return True
589 for prefix, matcherargs in subincludes:
590 if f.startswith(prefix):
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 598 return False
592 599 matchfuncs.append(matchsubinclude)
593 600
General Comments 0
You need to be logged in to leave comments. Login now