diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -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] diff --git a/tests/test-walk.t b/tests/test-walk.t --- a/tests/test-walk.t +++ b/tests/test-walk.t @@ -143,25 +143,25 @@ $ hg debugwalk -v 'rootfilesin:' * matcher: - + f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -v -I 'rootfilesin:' * matcher: - + f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -v 'rootfilesin:.' * matcher: - + f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead $ hg debugwalk -v -I 'rootfilesin:.' * matcher: - + f fennel ../fennel f fenugreek ../fenugreek f fiddlehead ../fiddlehead @@ -169,7 +169,7 @@ * matcher: , - m2=> + m2=> f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney @@ -182,19 +182,19 @@ f mammals/skunk skunk $ hg debugwalk -v 'rootfilesin:fennel' * matcher: - + $ hg debugwalk -v -I 'rootfilesin:fennel' * matcher: - + $ hg debugwalk -v 'rootfilesin:skunk' * matcher: - + $ hg debugwalk -v -I 'rootfilesin:skunk' * matcher: - + $ hg debugwalk -v 'rootfilesin:beans' * matcher: - + f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney @@ -203,7 +203,7 @@ f beans/turtle ../beans/turtle $ hg debugwalk -v -I 'rootfilesin:beans' * matcher: - + f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney @@ -212,25 +212,25 @@ f beans/turtle ../beans/turtle $ hg debugwalk -v 'rootfilesin:mammals' * matcher: - + f mammals/skunk skunk $ hg debugwalk -v -I 'rootfilesin:mammals' * matcher: - + f mammals/skunk skunk $ hg debugwalk -v 'rootfilesin:mammals/' * matcher: - + f mammals/skunk skunk $ hg debugwalk -v -I 'rootfilesin:mammals/' * matcher: - + f mammals/skunk skunk $ hg debugwalk -v -X 'rootfilesin:mammals' * matcher: , - m2=> + m2=> f beans/black ../beans/black f beans/borlotti ../beans/borlotti f beans/kidney ../beans/kidney