diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -95,6 +95,24 @@ def _kindpatsalwaysmatch(kindpats): return False return True +def _buildkindpatsmatcher(matchercls, root, cwd, kindpats, ctx=None, + listsubrepos=False, badfn=None): + fset, kindpats = _expandsets(kindpats, ctx, listsubrepos) + matchers = [] + if kindpats: + m = matchercls(root, cwd, kindpats, ctx=ctx, listsubrepos=listsubrepos, + badfn=badfn) + matchers.append(m) + if fset: + m = predicatematcher(root, cwd, fset.__contains__, + predrepr='fileset', badfn=badfn) + matchers.append(m) + if not matchers: + return nevermatcher(root, cwd, badfn=badfn) + if len(matchers) == 1: + return matchers[0] + return unionmatcher(matchers) + def match(root, cwd, patterns=None, include=None, exclude=None, default='glob', exact=False, auditor=None, ctx=None, listsubrepos=False, warn=None, badfn=None, icasefs=False): @@ -159,8 +177,9 @@ def match(root, cwd, patterns=None, incl if _kindpatsalwaysmatch(kindpats): m = alwaysmatcher(root, cwd, badfn, relativeuipath=True) else: - m = patternmatcher(root, cwd, kindpats, ctx=ctx, - listsubrepos=listsubrepos, badfn=badfn) + m = _buildkindpatsmatcher(patternmatcher, root, cwd, kindpats, + ctx=ctx, listsubrepos=listsubrepos, + badfn=badfn) else: # It's a little strange that no patterns means to match everything. # Consider changing this to match nothing (probably using nevermatcher). @@ -168,13 +187,13 @@ def match(root, cwd, patterns=None, incl if include: kindpats = normalize(include, 'glob', root, cwd, auditor, warn) - im = includematcher(root, cwd, kindpats, ctx=ctx, - listsubrepos=listsubrepos, badfn=None) + im = _buildkindpatsmatcher(includematcher, root, cwd, kindpats, ctx=ctx, + listsubrepos=listsubrepos, badfn=None) m = intersectmatchers(m, im) if exclude: kindpats = normalize(exclude, 'glob', root, cwd, auditor, warn) - em = includematcher(root, cwd, kindpats, ctx=ctx, - listsubrepos=listsubrepos, badfn=None) + em = _buildkindpatsmatcher(includematcher, root, cwd, kindpats, ctx=ctx, + listsubrepos=listsubrepos, badfn=None) m = differencematcher(m, em) return m @@ -828,10 +847,6 @@ def _buildmatch(ctx, kindpats, globsuffi globsuffix is appended to the regexp of globs.''' matchfuncs = [] - fset, kindpats = _expandsets(kindpats, ctx, listsubrepos) - if fset: - matchfuncs.append(fset.__contains__) - subincludes, kindpats = _expandsubinclude(kindpats, root) if subincludes: submatchers = {} diff --git a/tests/test-glog-beautifygraph.t b/tests/test-glog-beautifygraph.t --- a/tests/test-glog-beautifygraph.t +++ b/tests/test-glog-beautifygraph.t @@ -2023,25 +2023,14 @@ Test "set:..." and parent revision $ testlog "set:copied()" [] (func - (symbol '_matchfiles') - (list - (string 'r:') - (string 'd:relpath') - (string 'p:set:copied()'))) + (symbol 'filelog') + (string 'set:copied()')) , - > + , set([])> $ testlog --include "set:copied()" [] - (func - (symbol '_matchfiles') - (list - (string 'r:') - (string 'd:relpath') - (string 'i:set:copied()'))) - , - > + [] + $ testlog -r "sort(file('set:copied()'), -rev)" ["sort(file('set:copied()'), -rev)"] [] diff --git a/tests/test-glog.t b/tests/test-glog.t --- a/tests/test-glog.t +++ b/tests/test-glog.t @@ -1870,25 +1870,14 @@ Test "set:..." and parent revision $ testlog "set:copied()" [] (func - (symbol '_matchfiles') - (list - (string 'r:') - (string 'd:relpath') - (string 'p:set:copied()'))) + (symbol 'filelog') + (string 'set:copied()')) , - > + , set([])> $ testlog --include "set:copied()" [] - (func - (symbol '_matchfiles') - (list - (string 'r:') - (string 'd:relpath') - (string 'i:set:copied()'))) - , - > + [] + $ testlog -r "sort(file('set:copied()'), -rev)" ["sort(file('set:copied()'), -rev)"] []