diff -r 81e4f039a0cd -r 19ed212de2d1 mercurial/match.py --- a/mercurial/match.py Sat Oct 13 06:02:27 2018 -0400 +++ b/mercurial/match.py Sat Oct 13 00:22:05 2018 -0700 @@ -1164,8 +1164,20 @@ regex = '' if kindpats: - regex, mf = _buildregexmatch(kindpats, globsuffix) - matchfuncs.append(mf) + if all(k == 'rootfilesin' for k, p, s in kindpats): + dirs = {p for k, p, s in kindpats} + def mf(f): + i = f.rfind('/') + if i >= 0: + dir = f[:i] + else: + dir = '.' + return dir in dirs + regex = b'rootfilesin: %s' % sorted(dirs) + matchfuncs.append(mf) + else: + regex, mf = _buildregexmatch(kindpats, globsuffix) + matchfuncs.append(mf) if len(matchfuncs) == 1: return regex, matchfuncs[0]