##// END OF EJS Templates
includematcher: separate "parents" from "dirs"...
spectral -
r38989:5a7df82d default
parent child Browse files
Show More
@@ -445,11 +445,14 b' class includematcher(basematcher):'
445 self._pats, self.matchfn = _buildmatch(kindpats, '(?:/|$)',
445 self._pats, self.matchfn = _buildmatch(kindpats, '(?:/|$)',
446 listsubrepos, root)
446 listsubrepos, root)
447 self._prefix = _prefix(kindpats)
447 self._prefix = _prefix(kindpats)
448 roots, dirs = _rootsanddirs(kindpats)
448 roots, dirs, parents = _rootsdirsandparents(kindpats)
449 # roots are directories which are recursively included.
449 # roots are directories which are recursively included.
450 self._roots = set(roots)
450 self._roots = set(roots)
451 # dirs are directories which are non-recursively included.
451 # dirs are directories which are non-recursively included.
452 self._dirs = set(dirs)
452 self._dirs = set(dirs)
453 # parents are directories which are non-recursively included because
454 # they are needed to get to items in _dirs or _roots.
455 self._parents = set(parents)
453
456
454 def visitdir(self, dir):
457 def visitdir(self, dir):
455 if self._prefix and dir in self._roots:
458 if self._prefix and dir in self._roots:
@@ -457,6 +460,7 b' class includematcher(basematcher):'
457 return ('.' in self._roots or
460 return ('.' in self._roots or
458 dir in self._roots or
461 dir in self._roots or
459 dir in self._dirs or
462 dir in self._dirs or
463 dir in self._parents or
460 any(parentdir in self._roots
464 any(parentdir in self._roots
461 for parentdir in util.finddirs(dir)))
465 for parentdir in util.finddirs(dir)))
462
466
@@ -1004,7 +1008,7 b' def _roots(kindpats):'
1004 roots, dirs = _patternrootsanddirs(kindpats)
1008 roots, dirs = _patternrootsanddirs(kindpats)
1005 return roots
1009 return roots
1006
1010
1007 def _rootsanddirs(kindpats):
1011 def _rootsdirsandparents(kindpats):
1008 '''Returns roots and exact directories from patterns.
1012 '''Returns roots and exact directories from patterns.
1009
1013
1010 roots are directories to match recursively, whereas exact directories should
1014 roots are directories to match recursively, whereas exact directories should
@@ -1012,32 +1016,33 b' def _rootsanddirs(kindpats):'
1012 include directories that need to be implicitly considered as either, such as
1016 include directories that need to be implicitly considered as either, such as
1013 parent directories.
1017 parent directories.
1014
1018
1015 >>> _rootsanddirs(
1019 >>> _rootsdirsandparents(
1016 ... [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
1020 ... [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
1017 ... (b'glob', b'g*', b'')])
1021 ... (b'glob', b'g*', b'')])
1018 (['g/h', 'g/h', '.'], ['g', '.'])
1022 (['g/h', 'g/h', '.'], [], ['g', '.'])
1019 >>> _rootsanddirs(
1023 >>> _rootsdirsandparents(
1020 ... [(b'rootfilesin', b'g/h', b''), (b'rootfilesin', b'', b'')])
1024 ... [(b'rootfilesin', b'g/h', b''), (b'rootfilesin', b'', b'')])
1021 ([], ['g/h', '.', 'g', '.'])
1025 ([], ['g/h', '.'], ['g', '.'])
1022 >>> _rootsanddirs(
1026 >>> _rootsdirsandparents(
1023 ... [(b'relpath', b'r', b''), (b'path', b'p/p', b''),
1027 ... [(b'relpath', b'r', b''), (b'path', b'p/p', b''),
1024 ... (b'path', b'', b'')])
1028 ... (b'path', b'', b'')])
1025 (['r', 'p/p', '.'], ['p', '.'])
1029 (['r', 'p/p', '.'], [], ['p', '.'])
1026 >>> _rootsanddirs(
1030 >>> _rootsdirsandparents(
1027 ... [(b'relglob', b'rg*', b''), (b're', b're/', b''),
1031 ... [(b'relglob', b'rg*', b''), (b're', b're/', b''),
1028 ... (b'relre', b'rr', b'')])
1032 ... (b'relre', b'rr', b'')])
1029 (['.', '.', '.'], ['.'])
1033 (['.', '.', '.'], [], ['.'])
1030 '''
1034 '''
1031 r, d = _patternrootsanddirs(kindpats)
1035 r, d = _patternrootsanddirs(kindpats)
1032
1036
1037 p = []
1033 # Append the parents as non-recursive/exact directories, since they must be
1038 # Append the parents as non-recursive/exact directories, since they must be
1034 # scanned to get to either the roots or the other exact directories.
1039 # scanned to get to either the roots or the other exact directories.
1035 d.extend(util.dirs(d))
1040 p.extend(util.dirs(d))
1036 d.extend(util.dirs(r))
1041 p.extend(util.dirs(r))
1037 # util.dirs() does not include the root directory, so add it manually
1042 # util.dirs() does not include the root directory, so add it manually
1038 d.append('.')
1043 p.append('.')
1039
1044
1040 return r, d
1045 return r, d, p
1041
1046
1042 def _explicitfiles(kindpats):
1047 def _explicitfiles(kindpats):
1043 '''Returns the potential explicit filenames from the patterns.
1048 '''Returns the potential explicit filenames from the patterns.
General Comments 0
You need to be logged in to leave comments. Login now