Mercurial > hg
comparison mercurial/match.py @ 32503:361808a2b0b8
match: simplify includematcher a bit
The "include" we have in symbols is redundant and the double negative
in visitdir() can be removed.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 22 May 2017 23:31:15 -0700 |
parents | 3026f19b4b01 |
children | 2ba4d3b74ba8 |
comparison
equal
deleted
inserted
replaced
32502:3026f19b4b01 | 32503:361808a2b0b8 |
---|---|
408 super(includematcher, self).__init__(root, cwd, badfn) | 408 super(includematcher, self).__init__(root, cwd, badfn) |
409 | 409 |
410 kindpats = normalize(include, 'glob', root, cwd, auditor, warn) | 410 kindpats = normalize(include, 'glob', root, cwd, auditor, warn) |
411 self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)', | 411 self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)', |
412 listsubrepos, root) | 412 listsubrepos, root) |
413 self._anyincludepats = _anypats(kindpats) | 413 self._anypats = _anypats(kindpats) |
414 roots, dirs = _rootsanddirs(kindpats) | 414 roots, dirs = _rootsanddirs(kindpats) |
415 # roots are directories which are recursively included. | 415 # roots are directories which are recursively included. |
416 self._includeroots = set(roots) | 416 self._roots = set(roots) |
417 # dirs are directories which are non-recursively included. | 417 # dirs are directories which are non-recursively included. |
418 self._includedirs = set(dirs) | 418 self._dirs = set(dirs) |
419 self.matchfn = im | 419 self.matchfn = im |
420 | 420 |
421 def visitdir(self, dir): | 421 def visitdir(self, dir): |
422 if not self._anyincludepats and dir in self._includeroots: | 422 if not self._anypats and dir in self._roots: |
423 # The condition above is essentially self.prefix() for includes | 423 # The condition above is essentially self.prefix() for includes |
424 return 'all' | 424 return 'all' |
425 if ('.' not in self._includeroots and | 425 return ('.' in self._roots or |
426 dir not in self._includeroots and | 426 dir in self._roots or |
427 dir not in self._includedirs and | 427 dir in self._dirs or |
428 not any(parent in self._includeroots | 428 any(parentdir in self._roots |
429 for parent in util.finddirs(dir))): | 429 for parentdir in util.finddirs(dir))) |
430 return False | |
431 return True | |
432 | 430 |
433 def anypats(self): | 431 def anypats(self): |
434 return True | 432 return True |
435 | 433 |
436 def __repr__(self): | 434 def __repr__(self): |