comparison mercurial/match.py @ 38581:6467286b829c

match: remove ctx argument from code path down to _buildmatch() 'ctx' was there only for filesets.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 12 Jun 2018 22:01:59 +0900
parents 9f9ffe5f687c
children 0ba4cf3f088f
comparison
equal deleted inserted replaced
38580:9f9ffe5f687c 38581:6467286b829c
98 def _buildkindpatsmatcher(matchercls, root, cwd, kindpats, ctx=None, 98 def _buildkindpatsmatcher(matchercls, root, cwd, kindpats, ctx=None,
99 listsubrepos=False, badfn=None): 99 listsubrepos=False, badfn=None):
100 fset, kindpats = _expandsets(kindpats, ctx, listsubrepos) 100 fset, kindpats = _expandsets(kindpats, ctx, listsubrepos)
101 matchers = [] 101 matchers = []
102 if kindpats: 102 if kindpats:
103 m = matchercls(root, cwd, kindpats, ctx=ctx, listsubrepos=listsubrepos, 103 m = matchercls(root, cwd, kindpats, listsubrepos=listsubrepos,
104 badfn=badfn) 104 badfn=badfn)
105 matchers.append(m) 105 matchers.append(m)
106 if fset: 106 if fset:
107 m = predicatematcher(root, cwd, fset.__contains__, 107 m = predicatematcher(root, cwd, fset.__contains__,
108 predrepr='fileset', badfn=badfn) 108 predrepr='fileset', badfn=badfn)
408 or pycompat.byterepr(self.matchfn)) 408 or pycompat.byterepr(self.matchfn))
409 return '<predicatenmatcher pred=%s>' % s 409 return '<predicatenmatcher pred=%s>' % s
410 410
411 class patternmatcher(basematcher): 411 class patternmatcher(basematcher):
412 412
413 def __init__(self, root, cwd, kindpats, ctx=None, listsubrepos=False, 413 def __init__(self, root, cwd, kindpats, listsubrepos=False, badfn=None):
414 badfn=None):
415 super(patternmatcher, self).__init__(root, cwd, badfn) 414 super(patternmatcher, self).__init__(root, cwd, badfn)
416 415
417 self._files = _explicitfiles(kindpats) 416 self._files = _explicitfiles(kindpats)
418 self._prefix = _prefix(kindpats) 417 self._prefix = _prefix(kindpats)
419 self._pats, self.matchfn = _buildmatch(ctx, kindpats, '$', listsubrepos, 418 self._pats, self.matchfn = _buildmatch(kindpats, '$', listsubrepos,
420 root) 419 root)
421 420
422 @propertycache 421 @propertycache
423 def _dirs(self): 422 def _dirs(self):
424 return set(util.dirs(self._fileset)) | {'.'} 423 return set(util.dirs(self._fileset)) | {'.'}
439 def __repr__(self): 438 def __repr__(self):
440 return ('<patternmatcher patterns=%r>' % pycompat.bytestr(self._pats)) 439 return ('<patternmatcher patterns=%r>' % pycompat.bytestr(self._pats))
441 440
442 class includematcher(basematcher): 441 class includematcher(basematcher):
443 442
444 def __init__(self, root, cwd, kindpats, ctx=None, listsubrepos=False, 443 def __init__(self, root, cwd, kindpats, listsubrepos=False, badfn=None):
445 badfn=None):
446 super(includematcher, self).__init__(root, cwd, badfn) 444 super(includematcher, self).__init__(root, cwd, badfn)
447 445
448 self._pats, self.matchfn = _buildmatch(ctx, kindpats, '(?:/|$)', 446 self._pats, self.matchfn = _buildmatch(kindpats, '(?:/|$)',
449 listsubrepos, root) 447 listsubrepos, root)
450 self._prefix = _prefix(kindpats) 448 self._prefix = _prefix(kindpats)
451 roots, dirs = _rootsanddirs(kindpats) 449 roots, dirs = _rootsanddirs(kindpats)
452 # roots are directories which are recursively included. 450 # roots are directories which are recursively included.
453 self._roots = set(roots) 451 self._roots = set(roots)
840 return '.*' + pat 838 return '.*' + pat
841 if kind == 'glob': 839 if kind == 'glob':
842 return _globre(pat) + globsuffix 840 return _globre(pat) + globsuffix
843 raise error.ProgrammingError('not a regex pattern: %s:%s' % (kind, pat)) 841 raise error.ProgrammingError('not a regex pattern: %s:%s' % (kind, pat))
844 842
845 def _buildmatch(ctx, kindpats, globsuffix, listsubrepos, root): 843 def _buildmatch(kindpats, globsuffix, listsubrepos, root):
846 '''Return regexp string and a matcher function for kindpats. 844 '''Return regexp string and a matcher function for kindpats.
847 globsuffix is appended to the regexp of globs.''' 845 globsuffix is appended to the regexp of globs.'''
848 matchfuncs = [] 846 matchfuncs = []
849 847
850 subincludes, kindpats = _expandsubinclude(kindpats, root) 848 subincludes, kindpats = _expandsubinclude(kindpats, root)