changeset 50689:a45460e235a2 stable

re2: fix reporting of availability in `hg debuginstall` We add and use an official API to check is re2 is available. This prevent the bug previously in place were debuginstall was considering confusing `None` (i.e. non-initialized) and `False` (i.e. unavailable).
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 17 Jun 2023 04:05:53 +0200
parents 293e1763982e
children ae74a60ad583
files mercurial/debugcommands.py mercurial/util.py
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Sat Jun 17 04:05:18 2023 +0200
+++ b/mercurial/debugcommands.py	Sat Jun 17 04:05:53 2023 +0200
@@ -2137,7 +2137,7 @@
         ),
     )
     re2 = b'missing'
-    if util._re2:
+    if util.has_re2():
         re2 = b'available'
     fm.plain(_(b'checking "re2" regexp engine (%s)\n') % re2)
     fm.data(re2=bool(util._re2))
--- a/mercurial/util.py	Sat Jun 17 04:05:18 2023 +0200
+++ b/mercurial/util.py	Sat Jun 17 04:05:53 2023 +0200
@@ -2210,6 +2210,13 @@
     _re2 = False
 
 
+def has_re2():
+    """return True is re2 is available, False otherwise"""
+    if _re2 is None:
+        _re._checkre2()
+    return _re2
+
+
 class _re:
     @staticmethod
     def _checkre2():