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

login
register
mail settings
Submitter Simon Heimberg
Date July 1, 2013, 4:52 a.m.
Message ID <9c97c44192062eea19b9.1372654336@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1772/
State Accepted
Commit dd7c992d3cc1c2d1b557bbdecda1b2f3b0abdfa0
Headers show

Comments

Simon Heimberg - July 1, 2013, 4:52 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1372654258 -7200
# Node ID 9c97c44192062eea19b956c5d9697a4790ceee2b
# Parent  77440de177f799f9f3bd6236c5b45fb8e15687e7
util: check if re2 works before using it (issue 3964)
Matt Mackall - July 19, 2013, 4:37 a.m.
On Mon, 2013-07-01 at 06:52 +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1372654258 -7200
> # Node ID 9c97c44192062eea19b956c5d9697a4790ceee2b
> # Parent  77440de177f799f9f3bd6236c5b45fb8e15687e7
> util: check if re2 works before using it (issue 3964)

Manually tested and queued for default, thanks.

Patch

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: