Mercurial > public > mercurial-scm > hg-stable
diff mercurial/match.py @ 38479:67dc32d4e790
cleanup: migrate from re.escape to stringutil.reescape
This has consistent behavior on Python 2.7, 3.6, and 3.7 and has the
benefit of probably being a little faster. Test output changes are
largely because / used to be pointlessly escaped.
Differential Revision: https://phab.mercurial-scm.org/D3842
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 26 Jun 2018 10:36:23 -0400 |
parents | 2f406142d7b4 |
children | 76838305b9dd |
line wrap: on
line diff
--- a/mercurial/match.py Tue Jun 26 10:33:52 2018 -0400 +++ b/mercurial/match.py Tue Jun 26 10:36:23 2018 -0400 @@ -714,7 +714,7 @@ >>> bprint(_globre(br'**/a')) (?:.*/)?a >>> bprint(_globre(br'a/**/b')) - a\/(?:.*/)?b + a/(?:.*/)?b >>> bprint(_globre(br'[a*?!^][^b][!c]')) [a*?!^][\^b][^c] >>> bprint(_globre(br'{a,b}')) @@ -725,7 +725,7 @@ i, n = 0, len(pat) res = '' group = 0 - escape = util.re.escape + escape = util.stringutil.reescape def peek(): return i < n and pat[i:i + 1] while i < n: @@ -790,13 +790,13 @@ if kind in ('path', 'relpath'): if pat == '.': return '' - return util.re.escape(pat) + '(?:/|$)' + return util.stringutil.reescape(pat) + '(?:/|$)' if kind == 'rootfilesin': if pat == '.': escaped = '' else: # Pattern is a directory name. - escaped = util.re.escape(pat) + '/' + escaped = util.stringutil.reescape(pat) + '/' # Anything after the pattern must be a non-directory. return escaped + '[^/]+$' if kind == 'relglob':