comparison mercurial/match.py @ 32461:2b5953a49f14

match: fix visitdir for roots of includes I'm hoping to rewrite the matcher so excludes are handled by composition of one matcher with another matcher where the second matcher has only includes. For that to work, we need to make visitdir() to return 'all' for directory 'foo' for a '-I foo' matcher.
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 16 May 2017 14:31:21 -0700
parents f9445b528687
children 43e091847c4d
comparison
equal deleted inserted replaced
32460:f9445b528687 32461:2b5953a49f14
305 include = [] 305 include = []
306 if exclude is None: 306 if exclude is None:
307 exclude = [] 307 exclude = []
308 308
309 self._anypats = bool(include or exclude) 309 self._anypats = bool(include or exclude)
310 self._anyincludepats = False
310 self._always = False 311 self._always = False
311 self._pathrestricted = bool(include or exclude or patterns) 312 self._pathrestricted = bool(include or exclude or patterns)
312 self.patternspat = None 313 self.patternspat = None
313 self.includepat = None 314 self.includepat = None
314 self.excludepat = None 315 self.excludepat = None
322 matchfns = [] 323 matchfns = []
323 if include: 324 if include:
324 kindpats = normalize(include, 'glob', root, cwd, auditor, warn) 325 kindpats = normalize(include, 'glob', root, cwd, auditor, warn)
325 self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)', 326 self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)',
326 listsubrepos, root) 327 listsubrepos, root)
328 self._anyincludepats = _anypats(kindpats)
327 roots, dirs = _rootsanddirs(kindpats) 329 roots, dirs = _rootsanddirs(kindpats)
328 self._includeroots.update(roots) 330 self._includeroots.update(roots)
329 self._includedirs.update(dirs) 331 self._includedirs.update(dirs)
330 matchfns.append(im) 332 matchfns.append(im)
331 if exclude: 333 if exclude:
379 def visitdir(self, dir): 381 def visitdir(self, dir):
380 if self.prefix() and dir in self._fileset: 382 if self.prefix() and dir in self._fileset:
381 return 'all' 383 return 'all'
382 if dir in self._excluderoots: 384 if dir in self._excluderoots:
383 return False 385 return False
384 if ((self._includeroots or self._includedirs) and 386 if self._includeroots or self._includedirs:
385 '.' not in self._includeroots and 387 if (not self._anyincludepats and
386 dir not in self._includeroots and 388 not self._excluderoots and
387 dir not in self._includedirs and 389 dir in self._includeroots):
388 not any(parent in self._includeroots 390 # The condition above is essentially self.prefix() for includes
389 for parent in util.finddirs(dir))): 391 return 'all'
390 return False 392 if ('.' not in self._includeroots and
393 dir not in self._includeroots and
394 dir not in self._includedirs and
395 not any(parent in self._includeroots
396 for parent in util.finddirs(dir))):
397 return False
391 return (not self._fileset or 398 return (not self._fileset or
392 '.' in self._fileset or 399 '.' in self._fileset or
393 dir in self._fileset or 400 dir in self._fileset or
394 dir in self._dirs or 401 dir in self._dirs or
395 any(parentdir in self._fileset 402 any(parentdir in self._fileset