comparison mercurial/util.py @ 19461:dd7c992d3cc1

util: check if re2 works before using it (issue 3964)
author Simon Heimberg <simohe@besonet.ch>
date Mon, 01 Jul 2013 06:50:58 +0200
parents 8b04e1344111
children 887ffa22fd0d a1237a4b437d
comparison
equal deleted inserted replaced
19460:d876c82f25a3 19461:dd7c992d3cc1
671 only flags from the re module that are re2-compatible are 671 only flags from the re module that are re2-compatible are
672 IGNORECASE and MULTILINE.''' 672 IGNORECASE and MULTILINE.'''
673 global _re2 673 global _re2
674 if _re2 is None: 674 if _re2 is None:
675 try: 675 try:
676 re2.compile 676 # check if match works, see issue3964
677 _re2 = True 677 _re2 = bool(re2.match(r'\[([^\[]+)\]', '[ui]'))
678 except ImportError: 678 except ImportError:
679 _re2 = False 679 _re2 = False
680 if _re2 and (flags & ~(re.IGNORECASE | re.MULTILINE)) == 0: 680 if _re2 and (flags & ~(re.IGNORECASE | re.MULTILINE)) == 0:
681 if flags & re.IGNORECASE: 681 if flags & re.IGNORECASE:
682 pat = '(?i)' + pat 682 pat = '(?i)' + pat