[PATCH "FIX-RE2] match: fix re2 compability broken in 2e2699af5649

Martin von Zweigbergk martinvonz at google.com
Thu Apr 11 12:48:42 EDT 2019


On Thu, Apr 11, 2019 at 9:46 AM Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at octobus.net>
> # Date 1555000496 -7200
> #      Thu Apr 11 18:34:56 2019 +0200
> # Node ID ca4f233c0f5c4ca5604a53c01216a16d136c69d8
> # Parent  509a0477b3a6e9f1ea0fe32bfb028c256aada7fa
> # EXP-Topic fix-2e2699af5649
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> ca4f233c0f5c
> match: fix re2 compability broken in 2e2699af5649
>
> Apparently, the re2 regex matcher return False when no match are found.


This is not quite true; we explicitly use a different method on the
compiled regex when we use re2:
https://www.mercurial-scm.org/repo/hg/file/509a0477b3a6/mercurial/match.py#l41


> So since
> 2e2699af5649 running test on a machine with a re2 install fails in many
> places.
> Instead we make the code a bit more general and everything goes back to
> normal.
>
> diff --git a/mercurial/match.py b/mercurial/match.py
> --- a/mercurial/match.py
> +++ b/mercurial/match.py
> @@ -1288,7 +1288,7 @@ def _buildregexmatch(kindpats, globsuffi
>
>          if startidx == 0:
>              matcher = _rematcher(fullregexp)
> -            func = lambda s: matcher(s) is not None
> +            func = lambda s: bool(matcher(s))
>          else:
>              group = regexps[startidx:]
>              allgroups.append(_joinregexes(group))
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20190411/62c9227e/attachment.html>


More information about the Mercurial-devel mailing list