match: combine regex code for path: and relpath:
The regexes for path: and relpath: patterns are the same (since the
paths have already been normalized at the point we create the
regexes).
I don't think the "if pat == '.'" will have any effect relpath:
because relpath: patterns will have the root directory already
normalized to '' by pathutil.canonpath() (unlike path:, for which the
root gets normalized to '.' by util.normpath()).
--- a/mercurial/match.py Sun Jul 09 22:53:02 2017 -0700
+++ b/mercurial/match.py Sun Jul 09 23:01:11 2017 -0700
@@ -794,7 +794,7 @@
return ''
if kind == 're':
return pat
- if kind == 'path':
+ if kind in ('path', 'relpath'):
if pat == '.':
return ''
return util.re.escape(pat) + '(?:/|$)'
@@ -808,8 +808,6 @@
return escaped + '[^/]+$'
if kind == 'relglob':
return '(?:|.*/)' + _globre(pat) + globsuffix
- if kind == 'relpath':
- return util.re.escape(pat) + '(?:/|$)'
if kind == 'relre':
if pat.startswith('^'):
return pat