mercurial/match.py
changeset 33448 04be8aec44a8
parent 33447 6f4e5e5940a5
child 33478 cf15c3cc304c
equal deleted inserted replaced
33447:6f4e5e5940a5 33448:04be8aec44a8
   646     def __repr__(self):
   646     def __repr__(self):
   647         return ('<subdirmatcher path=%r, matcher=%r>' %
   647         return ('<subdirmatcher path=%r, matcher=%r>' %
   648                 (self._path, self._matcher))
   648                 (self._path, self._matcher))
   649 
   649 
   650 class unionmatcher(basematcher):
   650 class unionmatcher(basematcher):
   651     """A matcher that is the union of several matchers."""
   651     """A matcher that is the union of several matchers.
       
   652 
       
   653     The non-matching-attributes (root, cwd, bad, explicitdir, traversedir) are
       
   654     taken from the first matcher.
       
   655     """
       
   656 
   652     def __init__(self, matchers):
   657     def __init__(self, matchers):
       
   658         m1 = matchers[0]
       
   659         super(unionmatcher, self).__init__(m1._root, m1._cwd)
       
   660         self.explicitdir = m1.explicitdir
       
   661         self.traversedir = m1.traversedir
   653         self._matchers = matchers
   662         self._matchers = matchers
   654 
   663 
   655     def matchfn(self, f):
   664     def matchfn(self, f):
   656         for match in self._matchers:
   665         for match in self._matchers:
   657             if match(f):
   666             if match(f):
   658                 return True
   667                 return True
   659         return False
   668         return False
       
   669 
       
   670     def visitdir(self, dir):
       
   671         r = False
       
   672         for m in self._matchers:
       
   673             v = m.visitdir(dir)
       
   674             if v == 'all':
       
   675                 return v
       
   676             r |= v
       
   677         return r
   660 
   678 
   661     def __repr__(self):
   679     def __repr__(self):
   662         return ('<unionmatcher matchers=%r>' % self._matchers)
   680         return ('<unionmatcher matchers=%r>' % self._matchers)
   663 
   681 
   664 class negatematcher(basematcher):
   682 class negatematcher(basematcher):