match: combine regex code for path: and relpath:
authorMartin von Zweigbergk <martinvonz@google.com>
Sun, 09 Jul 2017 23:01:11 -0700
changeset 33358 38b6122df5c7
parent 33357 a21819f439fe
child 33359 583aa1e3658b
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()).
mercurial/match.py
--- 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