mercurial/util.py
changeset 1446 4babaa52badf
parent 1420 b32b3509c7ab
child 1454 f4250806dbeb
equal deleted inserted replaced
1445:56281e086f38 1446:4babaa52badf
   244             return '.*' + name
   244             return '.*' + name
   245         return head + globre(name, '', tail)
   245         return head + globre(name, '', tail)
   246 
   246 
   247     def matchfn(pats, tail):
   247     def matchfn(pats, tail):
   248         """build a matching function from a set of patterns"""
   248         """build a matching function from a set of patterns"""
   249         if pats:
   249         matches = []
   250             pat = '(?:%s)' % '|'.join([regex(k, p, tail) for (k, p) in pats])
   250         for k, p in pats:
   251             return re.compile(pat).match
   251             try:
       
   252                 pat = '(?:%s)' % regex(k, p, tail)
       
   253                 matches.append(re.compile(pat).match)
       
   254             except re.error, inst:
       
   255                 raise Abort("invalid pattern: %s:%s" % (k, p))
       
   256 
       
   257         def buildfn(text):
       
   258             for m in matches:
       
   259                 r = m(text)
       
   260                 if r:
       
   261                     return r
       
   262 
       
   263         return buildfn
   252 
   264 
   253     def globprefix(pat):
   265     def globprefix(pat):
   254         '''return the non-glob prefix of a path, e.g. foo/* -> foo'''
   266         '''return the non-glob prefix of a path, e.g. foo/* -> foo'''
   255         root = []
   267         root = []
   256         for p in pat.split(os.sep):
   268         for p in pat.split(os.sep):