##// END OF EJS Templates
match: compose 'set:' pattern as matcher...
Yuya Nishihara -
r38836:9f9ffe5f default
parent child Browse files
Show More
@@ -95,6 +95,24 b' def _kindpatsalwaysmatch(kindpats):'
95 return False
95 return False
96 return True
96 return True
97
97
98 def _buildkindpatsmatcher(matchercls, root, cwd, kindpats, ctx=None,
99 listsubrepos=False, badfn=None):
100 fset, kindpats = _expandsets(kindpats, ctx, listsubrepos)
101 matchers = []
102 if kindpats:
103 m = matchercls(root, cwd, kindpats, ctx=ctx, listsubrepos=listsubrepos,
104 badfn=badfn)
105 matchers.append(m)
106 if fset:
107 m = predicatematcher(root, cwd, fset.__contains__,
108 predrepr='fileset', badfn=badfn)
109 matchers.append(m)
110 if not matchers:
111 return nevermatcher(root, cwd, badfn=badfn)
112 if len(matchers) == 1:
113 return matchers[0]
114 return unionmatcher(matchers)
115
98 def match(root, cwd, patterns=None, include=None, exclude=None, default='glob',
116 def match(root, cwd, patterns=None, include=None, exclude=None, default='glob',
99 exact=False, auditor=None, ctx=None, listsubrepos=False, warn=None,
117 exact=False, auditor=None, ctx=None, listsubrepos=False, warn=None,
100 badfn=None, icasefs=False):
118 badfn=None, icasefs=False):
@@ -159,8 +177,9 b' def match(root, cwd, patterns=None, incl'
159 if _kindpatsalwaysmatch(kindpats):
177 if _kindpatsalwaysmatch(kindpats):
160 m = alwaysmatcher(root, cwd, badfn, relativeuipath=True)
178 m = alwaysmatcher(root, cwd, badfn, relativeuipath=True)
161 else:
179 else:
162 m = patternmatcher(root, cwd, kindpats, ctx=ctx,
180 m = _buildkindpatsmatcher(patternmatcher, root, cwd, kindpats,
163 listsubrepos=listsubrepos, badfn=badfn)
181 ctx=ctx, listsubrepos=listsubrepos,
182 badfn=badfn)
164 else:
183 else:
165 # It's a little strange that no patterns means to match everything.
184 # It's a little strange that no patterns means to match everything.
166 # Consider changing this to match nothing (probably using nevermatcher).
185 # Consider changing this to match nothing (probably using nevermatcher).
@@ -168,12 +187,12 b' def match(root, cwd, patterns=None, incl'
168
187
169 if include:
188 if include:
170 kindpats = normalize(include, 'glob', root, cwd, auditor, warn)
189 kindpats = normalize(include, 'glob', root, cwd, auditor, warn)
171 im = includematcher(root, cwd, kindpats, ctx=ctx,
190 im = _buildkindpatsmatcher(includematcher, root, cwd, kindpats, ctx=ctx,
172 listsubrepos=listsubrepos, badfn=None)
191 listsubrepos=listsubrepos, badfn=None)
173 m = intersectmatchers(m, im)
192 m = intersectmatchers(m, im)
174 if exclude:
193 if exclude:
175 kindpats = normalize(exclude, 'glob', root, cwd, auditor, warn)
194 kindpats = normalize(exclude, 'glob', root, cwd, auditor, warn)
176 em = includematcher(root, cwd, kindpats, ctx=ctx,
195 em = _buildkindpatsmatcher(includematcher, root, cwd, kindpats, ctx=ctx,
177 listsubrepos=listsubrepos, badfn=None)
196 listsubrepos=listsubrepos, badfn=None)
178 m = differencematcher(m, em)
197 m = differencematcher(m, em)
179 return m
198 return m
@@ -828,10 +847,6 b' def _buildmatch(ctx, kindpats, globsuffi'
828 globsuffix is appended to the regexp of globs.'''
847 globsuffix is appended to the regexp of globs.'''
829 matchfuncs = []
848 matchfuncs = []
830
849
831 fset, kindpats = _expandsets(kindpats, ctx, listsubrepos)
832 if fset:
833 matchfuncs.append(fset.__contains__)
834
835 subincludes, kindpats = _expandsubinclude(kindpats, root)
850 subincludes, kindpats = _expandsubinclude(kindpats, root)
836 if subincludes:
851 if subincludes:
837 submatchers = {}
852 submatchers = {}
@@ -2023,25 +2023,14 b' Test "set:..." and parent revision'
2023 $ testlog "set:copied()"
2023 $ testlog "set:copied()"
2024 []
2024 []
2025 (func
2025 (func
2026 (symbol '_matchfiles')
2026 (symbol 'filelog')
2027 (list
2027 (string 'set:copied()'))
2028 (string 'r:')
2029 (string 'd:relpath')
2030 (string 'p:set:copied()')))
2031 <filteredset
2028 <filteredset
2032 <spanset- 0:7>,
2029 <spanset- 0:7>, set([])>
2033 <matchfiles patterns=['set:copied()'], include=[] exclude=[], default='relpath', rev=2147483647>>
2034 $ testlog --include "set:copied()"
2030 $ testlog --include "set:copied()"
2035 []
2031 []
2036 (func
2032 []
2037 (symbol '_matchfiles')
2033 <spanset- 0:7>
2038 (list
2039 (string 'r:')
2040 (string 'd:relpath')
2041 (string 'i:set:copied()')))
2042 <filteredset
2043 <spanset- 0:7>,
2044 <matchfiles patterns=[], include=['set:copied()'] exclude=[], default='relpath', rev=2147483647>>
2045 $ testlog -r "sort(file('set:copied()'), -rev)"
2034 $ testlog -r "sort(file('set:copied()'), -rev)"
2046 ["sort(file('set:copied()'), -rev)"]
2035 ["sort(file('set:copied()'), -rev)"]
2047 []
2036 []
@@ -1870,25 +1870,14 b' Test "set:..." and parent revision'
1870 $ testlog "set:copied()"
1870 $ testlog "set:copied()"
1871 []
1871 []
1872 (func
1872 (func
1873 (symbol '_matchfiles')
1873 (symbol 'filelog')
1874 (list
1874 (string 'set:copied()'))
1875 (string 'r:')
1876 (string 'd:relpath')
1877 (string 'p:set:copied()')))
1878 <filteredset
1875 <filteredset
1879 <spanset- 0:7>,
1876 <spanset- 0:7>, set([])>
1880 <matchfiles patterns=['set:copied()'], include=[] exclude=[], default='relpath', rev=2147483647>>
1881 $ testlog --include "set:copied()"
1877 $ testlog --include "set:copied()"
1882 []
1878 []
1883 (func
1879 []
1884 (symbol '_matchfiles')
1880 <spanset- 0:7>
1885 (list
1886 (string 'r:')
1887 (string 'd:relpath')
1888 (string 'i:set:copied()')))
1889 <filteredset
1890 <spanset- 0:7>,
1891 <matchfiles patterns=[], include=['set:copied()'] exclude=[], default='relpath', rev=2147483647>>
1892 $ testlog -r "sort(file('set:copied()'), -rev)"
1881 $ testlog -r "sort(file('set:copied()'), -rev)"
1893 ["sort(file('set:copied()'), -rev)"]
1882 ["sort(file('set:copied()'), -rev)"]
1894 []
1883 []
General Comments 0
You need to be logged in to leave comments. Login now