[PATCH 1 of 1 4test] util: check if re2 works before using it (issue 3964)

Simon Heimberg simohe at besonet.ch
Sun Jun 30 23:52:16 CDT 2013


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1372654258 -7200
# Node ID 9c97c44192062eea19b956c5d9697a4790ceee2b
# Parent  77440de177f799f9f3bd6236c5b45fb8e15687e7
util: check if re2 works before using it (issue 3964)

diff -r 77440de177f7 -r 9c97c4419206 mercurial/util.py
--- a/mercurial/util.py	Mit Jun 26 23:12:55 2013 +0200
+++ 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
+            _re2 = bool(re2.match(r'\[([^\[]+)\]', '[ui]'))
+                   # check if match works, see issue3964
         except ImportError:
             _re2 = False
     if _re2 and (flags & ~(re.IGNORECASE | re.MULTILINE)) == 0:


More information about the Mercurial-devel mailing list