mercurial/util.py
changeset 16943 8d08a28aa63e
parent 16873 37e081609828
child 17203 0cb55b5c19a3
equal deleted inserted replaced
16942:87882c8753d4 16943:8d08a28aa63e
   627             return False
   627             return False
   628         return True
   628         return True
   629     except OSError:
   629     except OSError:
   630         return True
   630         return True
   631 
   631 
       
   632 try:
       
   633     import re2
       
   634     _re2 = None
       
   635 except ImportError:
       
   636     _re2 = False
       
   637 
       
   638 def compilere(pat):
       
   639     '''Compile a regular expression, using re2 if possible
       
   640 
       
   641     For best performance, use only re2-compatible regexp features.'''
       
   642     global _re2
       
   643     if _re2 is None:
       
   644         try:
       
   645             re2.compile
       
   646             _re2 = True
       
   647         except ImportError:
       
   648             _re2 = False
       
   649     if _re2:
       
   650         try:
       
   651             return re2.compile(pat)
       
   652         except re2.error:
       
   653             pass
       
   654     return re.compile(pat)
       
   655 
   632 _fspathcache = {}
   656 _fspathcache = {}
   633 def fspath(name, root):
   657 def fspath(name, root):
   634     '''Get name in the case stored in the filesystem
   658     '''Get name in the case stored in the filesystem
   635 
   659 
   636     The name should be relative to root, and be normcase-ed for efficiency.
   660     The name should be relative to root, and be normcase-ed for efficiency.