util: check if re2 works before using it (issue 3964)
authorSimon Heimberg <simohe@besonet.ch>
Mon, 01 Jul 2013 06:50:58 +0200
changeset 19461 dd7c992d3cc1
parent 19460 d876c82f25a3
child 19462 a87d9102f7af
util: check if re2 works before using it (issue 3964)
mercurial/util.py
--- a/mercurial/util.py	Thu Jul 18 23:22:59 2013 -0500
+++ b/mercurial/util.py	Mon Jul 01 06:50:58 2013 +0200
@@ -673,8 +673,8 @@
     global _re2
     if _re2 is None:
         try:
-            re2.compile
-            _re2 = True
+            # check if match works, see issue3964
+            _re2 = bool(re2.match(r'\[([^\[]+)\]', '[ui]'))
         except ImportError:
             _re2 = False
     if _re2 and (flags & ~(re.IGNORECASE | re.MULTILINE)) == 0: