comparison mercurial/match.py @ 38579:ec0cee4c1fff

match: resolve 'set:' patterns first in _buildmatch() This just makes the next patch less complicated. The order of 'set:' and 'subinclude:' expansion doesn't matter.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 10 Jun 2018 15:52:27 +0900
parents 2d487b9cac07
children 9f9ffe5f687c
comparison
equal deleted inserted replaced
38578:2d487b9cac07 38579:ec0cee4c1fff
826 def _buildmatch(ctx, kindpats, globsuffix, listsubrepos, root): 826 def _buildmatch(ctx, kindpats, globsuffix, listsubrepos, root):
827 '''Return regexp string and a matcher function for kindpats. 827 '''Return regexp string and a matcher function for kindpats.
828 globsuffix is appended to the regexp of globs.''' 828 globsuffix is appended to the regexp of globs.'''
829 matchfuncs = [] 829 matchfuncs = []
830 830
831 fset, kindpats = _expandsets(kindpats, ctx, listsubrepos)
832 if fset:
833 matchfuncs.append(fset.__contains__)
834
831 subincludes, kindpats = _expandsubinclude(kindpats, root) 835 subincludes, kindpats = _expandsubinclude(kindpats, root)
832 if subincludes: 836 if subincludes:
833 submatchers = {} 837 submatchers = {}
834 def matchsubinclude(f): 838 def matchsubinclude(f):
835 for prefix, matcherargs in subincludes: 839 for prefix, matcherargs in subincludes:
841 845
842 if mf(f[len(prefix):]): 846 if mf(f[len(prefix):]):
843 return True 847 return True
844 return False 848 return False
845 matchfuncs.append(matchsubinclude) 849 matchfuncs.append(matchsubinclude)
846
847 fset, kindpats = _expandsets(kindpats, ctx, listsubrepos)
848 if fset:
849 matchfuncs.append(fset.__contains__)
850 850
851 regex = '' 851 regex = ''
852 if kindpats: 852 if kindpats:
853 regex, mf = _buildregexmatch(kindpats, globsuffix) 853 regex, mf = _buildregexmatch(kindpats, globsuffix)
854 matchfuncs.append(mf) 854 matchfuncs.append(mf)