mercurial/match.py
branchstable
changeset 43721 bfbbf48d51e8
parent 43117 8ff1ecfadcd1
child 43735 7eb701e355bd
equal deleted inserted replaced
43720:132470ee53fe 43721:bfbbf48d51e8
   552         return b''
   552         return b''
   553     return dir
   553     return dir
   554 
   554 
   555 
   555 
   556 class patternmatcher(basematcher):
   556 class patternmatcher(basematcher):
   557     """Matches a set of (kind, pat, source) against a 'root' directory.
   557     r"""Matches a set of (kind, pat, source) against a 'root' directory.
   558 
   558 
   559     >>> kindpats = [
   559     >>> kindpats = [
   560     ...     (b're', br'.*\.c$', b''),
   560     ...     (b're', br'.*\.c$', b''),
   561     ...     (b'path', b'foo/a', b''),
   561     ...     (b'path', b'foo/a', b''),
   562     ...     (b'relpath', b'b', b''),
   562     ...     (b'relpath', b'b', b''),
  1170     def __repr__(self):
  1170     def __repr__(self):
  1171         return b'<unionmatcher matchers=%r>' % self._matchers
  1171         return b'<unionmatcher matchers=%r>' % self._matchers
  1172 
  1172 
  1173 
  1173 
  1174 def patkind(pattern, default=None):
  1174 def patkind(pattern, default=None):
  1175     '''If pattern is 'kind:pat' with a known kind, return kind.
  1175     r'''If pattern is 'kind:pat' with a known kind, return kind.
  1176 
  1176 
  1177     >>> patkind(br're:.*\.c$')
  1177     >>> patkind(br're:.*\.c$')
  1178     're'
  1178     're'
  1179     >>> patkind(b'glob:*.c')
  1179     >>> patkind(b'glob:*.c')
  1180     'glob'
  1180     'glob'