##// END OF EJS Templates
match: add 'include:' syntax...
Durham Goode -
r25215:4040e06e default
parent child Browse files
Show More
@@ -75,6 +75,7 b' class match(object):'
75 75 'relpath:<path>' - a path relative to cwd
76 76 'relre:<regexp>' - a regexp that needn't match the start of a name
77 77 'set:<fileset>' - a fileset expression
78 'include:<path>' - a file of patterns to read and include
78 79 '<something>' - a pattern of the specified default type
79 80 """
80 81
@@ -228,6 +229,19 b' class match(object):'
228 229 auditor):
229 230 kindpats.append((k, p, pat))
230 231 continue
232 elif kind == 'include':
233 try:
234 includepats = readpatternfile(pat, self._warn)
235 for k, p, source in self._normalize(includepats, default,
236 root, cwd, auditor):
237 kindpats.append((k, p, source or pat))
238 except util.Abort, inst:
239 raise util.Abort('%s: %s' % (pat, inst[0]))
240 except IOError, inst:
241 if self._warn:
242 self._warn(_("skipping unreadable pattern file "
243 "'%s': %s\n") % (pat, inst.strerror))
244 continue
231 245 # else: re or relre - which cannot be normalized
232 246 kindpats.append((kind, pat, ''))
233 247 return kindpats
@@ -335,7 +349,7 b' def _patsplit(pattern, default):'
335 349 if ':' in pattern:
336 350 kind, pat = pattern.split(':', 1)
337 351 if kind in ('re', 'glob', 'path', 'relglob', 'relpath', 'relre',
338 'listfile', 'listfile0', 'set'):
352 'listfile', 'listfile0', 'set', 'include'):
339 353 return kind, pat
340 354 return default, pattern
341 355
@@ -515,7 +529,8 b' def readpatternfile(filepath, warn):'
515 529 '''parse a pattern file, returning a list of
516 530 patterns. These patterns should be given to compile()
517 531 to be validated and converted into a match function.'''
518 syntaxes = {'re': 'relre:', 'regexp': 'relre:', 'glob': 'relglob:'}
532 syntaxes = {'re': 'relre:', 'regexp': 'relre:', 'glob': 'relglob:',
533 'include': 'include'}
519 534 syntax = 'relre:'
520 535 patterns = []
521 536
@@ -167,3 +167,25 b' Check recursive glob pattern matches no '
167 167 ? a.c
168 168 ? a.o
169 169 ? syntax
170
171 Check using 'include:' in ignore file
172
173 $ hg purge --all --config extensions.purge=
174 $ touch foo.included
175
176 $ echo ".*.included" > otherignore
177 $ hg status -I "include:otherignore"
178 ? foo.included
179
180 $ echo "include:otherignore" >> .hgignore
181 $ hg status
182 A dir/b.o
183 ? .hgignore
184 ? otherignore
185
186 Check recursive uses of 'include:'
187
188 $ echo "include:nestedignore" >> otherignore
189 $ echo "glob:*ignore" > nestedignore
190 $ hg status
191 A dir/b.o
General Comments 0
You need to be logged in to leave comments. Login now