re2: fix reporting of availability in `hg debuginstall` stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 17 Jun 2023 04:05:53 +0200
branchstable
changeset 50689 a45460e235a2
parent 50688 293e1763982e
child 50690 ae74a60ad583
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).
mercurial/debugcommands.py
mercurial/util.py
--- 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():