mercurial/match.py
branchstable
changeset 51569 b32c3146ec34
parent 50695 1c31b343e514
child 51601 ea3343104f07
equal deleted inserted replaced
51568:2a89d2f6336f 51569:b32c3146ec34
   636 
   636 
   637     def __init__(self, root, kindpats, badfn=None):
   637     def __init__(self, root, kindpats, badfn=None):
   638         super(patternmatcher, self).__init__(badfn)
   638         super(patternmatcher, self).__init__(badfn)
   639         kindpats.sort()
   639         kindpats.sort()
   640 
   640 
       
   641         roots, dirs, parents = _rootsdirsandparents(kindpats)
   641         self._files = _explicitfiles(kindpats)
   642         self._files = _explicitfiles(kindpats)
       
   643         self._dirs_explicit = set(dirs)
       
   644         self._dirs = parents
   642         self._prefix = _prefix(kindpats)
   645         self._prefix = _prefix(kindpats)
   643         self._pats, self._matchfn = _buildmatch(kindpats, b'$', root)
   646         self._pats, self._matchfn = _buildmatch(kindpats, b'$', root)
   644 
   647 
   645     def matchfn(self, fn):
   648     def matchfn(self, fn):
   646         if fn in self._fileset:
   649         if fn in self._fileset:
   647             return True
   650             return True
   648         return self._matchfn(fn)
   651         return self._matchfn(fn)
   649 
   652 
   650     @propertycache
       
   651     def _dirs(self):
       
   652         return set(pathutil.dirs(self._fileset))
       
   653 
       
   654     def visitdir(self, dir):
   653     def visitdir(self, dir):
   655         if self._prefix and dir in self._fileset:
   654         if self._prefix and dir in self._fileset:
   656             return b'all'
   655             return b'all'
   657         return dir in self._dirs or path_or_parents_in_set(dir, self._fileset)
   656         return (
       
   657             dir in self._dirs
       
   658             or path_or_parents_in_set(dir, self._fileset)
       
   659             or path_or_parents_in_set(dir, self._dirs_explicit)
       
   660         )
   658 
   661 
   659     def visitchildrenset(self, dir):
   662     def visitchildrenset(self, dir):
   660         ret = self.visitdir(dir)
   663         ret = self.visitdir(dir)
   661         if ret is True:
   664         if ret is True:
   662             return b'this'
   665             return b'this'
  1459     """
  1462     """
  1460     try:
  1463     try:
  1461         allgroups = []
  1464         allgroups = []
  1462         regexps = []
  1465         regexps = []
  1463         exact = set()
  1466         exact = set()
  1464         for (kind, pattern, _source) in kindpats:
  1467         for kind, pattern, _source in kindpats:
  1465             if kind == b'filepath':
  1468             if kind == b'filepath':
  1466                 exact.add(pattern)
  1469                 exact.add(pattern)
  1467                 continue
  1470                 continue
  1468             regexps.append(_regex(kind, pattern, globsuffix))
  1471             regexps.append(_regex(kind, pattern, globsuffix))
  1469 
  1472