# HG changeset patch # User Pierre-Yves David # Date 1686967553 -7200 # Node ID a45460e235a244dba8faa1d3f81d24a8f9b1be92 # Parent 293e1763982ec8c2476c2b03dd7ce172bead4b1e 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). diff -r 293e1763982e -r a45460e235a2 mercurial/debugcommands.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)) diff -r 293e1763982e -r a45460e235a2 mercurial/util.py --- 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():