mercurial/match.py
changeset 32556 5f08eca8f8d3
parent 32555 b3083be7dcb9
child 32557 3fdcc34c0aba
equal deleted inserted replaced
32555:b3083be7dcb9 32556:5f08eca8f8d3
   143             return kindpats
   143             return kindpats
   144 
   144 
   145     if exact:
   145     if exact:
   146         m = exactmatcher(root, cwd, patterns, badfn)
   146         m = exactmatcher(root, cwd, patterns, badfn)
   147     elif patterns:
   147     elif patterns:
   148         m = patternmatcher(root, cwd, normalize, patterns, default=default,
   148         kindpats = normalize(patterns, default, root, cwd, auditor, warn)
   149                            auditor=auditor, ctx=ctx, listsubrepos=listsubrepos,
   149         m = patternmatcher(root, cwd, kindpats, ctx=ctx,
   150                            warn=warn, badfn=badfn)
   150                            listsubrepos=listsubrepos, badfn=badfn)
   151     else:
   151     else:
   152         # It's a little strange that no patterns means to match everything.
   152         # It's a little strange that no patterns means to match everything.
   153         # Consider changing this to match nothing (probably adding a
   153         # Consider changing this to match nothing (probably adding a
   154         # "nevermatcher").
   154         # "nevermatcher").
   155         m = alwaysmatcher(root, cwd, badfn)
   155         m = alwaysmatcher(root, cwd, badfn)
   156 
   156 
   157     if include:
   157     if include:
   158         im = includematcher(root, cwd, normalize, include, auditor=auditor,
   158         kindpats = normalize(include, 'glob', root, cwd, auditor, warn)
   159                             ctx=ctx, listsubrepos=listsubrepos, warn=warn,
   159         im = includematcher(root, cwd, kindpats, ctx=ctx,
   160                             badfn=None)
   160                             listsubrepos=listsubrepos, badfn=None)
   161         m = intersectmatchers(m, im)
   161         m = intersectmatchers(m, im)
   162     if exclude:
   162     if exclude:
   163         em = includematcher(root, cwd, normalize, exclude, auditor=auditor,
   163         kindpats = normalize(exclude, 'glob', root, cwd, auditor, warn)
   164                             ctx=ctx, listsubrepos=listsubrepos, warn=warn,
   164         em = includematcher(root, cwd, kindpats, ctx=ctx,
   165                             badfn=None)
   165                             listsubrepos=listsubrepos, badfn=None)
   166         m = differencematcher(m, em)
   166         m = differencematcher(m, em)
   167     return m
   167     return m
   168 
   168 
   169 def exact(root, cwd, files, badfn=None):
   169 def exact(root, cwd, files, badfn=None):
   170     return exactmatcher(root, cwd, files, badfn=badfn)
   170     return exactmatcher(root, cwd, files, badfn=badfn)
   336     def __repr__(self):
   336     def __repr__(self):
   337         return '<alwaysmatcher>'
   337         return '<alwaysmatcher>'
   338 
   338 
   339 class patternmatcher(basematcher):
   339 class patternmatcher(basematcher):
   340 
   340 
   341     def __init__(self, root, cwd, normalize, patterns, default='glob',
   341     def __init__(self, root, cwd, kindpats, ctx=None, listsubrepos=False,
   342                  auditor=None, ctx=None, listsubrepos=False, warn=None,
       
   343                  badfn=None):
   342                  badfn=None):
   344         super(patternmatcher, self).__init__(root, cwd, badfn)
   343         super(patternmatcher, self).__init__(root, cwd, badfn)
   345 
   344 
   346         kindpats = normalize(patterns, default, root, cwd, auditor, warn)
       
   347         if not _kindpatsalwaysmatch(kindpats):
   345         if not _kindpatsalwaysmatch(kindpats):
   348             self._files = _explicitfiles(kindpats)
   346             self._files = _explicitfiles(kindpats)
   349             self._anypats = _anypats(kindpats)
   347             self._anypats = _anypats(kindpats)
   350             self.patternspat, pm = _buildmatch(ctx, kindpats, '$',
   348             self.patternspat, pm = _buildmatch(ctx, kindpats, '$',
   351                                                listsubrepos, root)
   349                                                listsubrepos, root)
   381     def __repr__(self):
   379     def __repr__(self):
   382         return ('<patternmatcher patterns=%r>' % self.patternspat)
   380         return ('<patternmatcher patterns=%r>' % self.patternspat)
   383 
   381 
   384 class includematcher(basematcher):
   382 class includematcher(basematcher):
   385 
   383 
   386     def __init__(self, root, cwd, normalize, include, auditor=None, ctx=None,
   384     def __init__(self, root, cwd, kindpats, ctx=None, listsubrepos=False,
   387                  listsubrepos=False, warn=None, badfn=None):
   385                  badfn=None):
   388         super(includematcher, self).__init__(root, cwd, badfn)
   386         super(includematcher, self).__init__(root, cwd, badfn)
   389 
   387 
   390         kindpats = normalize(include, 'glob', root, cwd, auditor, warn)
       
   391         self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)',
   388         self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)',
   392                                           listsubrepos, root)
   389                                           listsubrepos, root)
   393         self._anypats = _anypats(kindpats)
   390         self._anypats = _anypats(kindpats)
   394         roots, dirs = _rootsanddirs(kindpats)
   391         roots, dirs = _rootsanddirs(kindpats)
   395         # roots are directories which are recursively included.
   392         # roots are directories which are recursively included.