[PATCH 1 of 4] match: add root to _buildmatch

Durham Goode durham at fb.com
Wed May 20 16:57:33 CDT 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1431817920 25200
#      Sat May 16 16:12:00 2015 -0700
# Node ID aed26cd32a07f5e18065a521b4bc42afff2ccc5a
# Parent  dc562165044aaec642d9ead37299840555e2d48c
match: add root to _buildmatch

A future patch will make _buildmatch able to expand relative include patterns.
Doing so will require knowing the root of the repo, so let's go ahead and pass
it in.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -91,12 +91,12 @@ class match(object):
         if include:
             kindpats = self._normalize(include, 'glob', root, cwd, auditor)
             self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)',
-                                              listsubrepos)
+                                              listsubrepos, root)
             matchfns.append(im)
         if exclude:
             kindpats = self._normalize(exclude, 'glob', root, cwd, auditor)
             self.excludepat, em = _buildmatch(ctx, kindpats, '(?:/|$)',
-                                              listsubrepos)
+                                              listsubrepos, root)
             matchfns.append(lambda f: not em(f))
         if exact:
             if isinstance(patterns, list):
@@ -110,7 +110,7 @@ class match(object):
                 self._files = _roots(kindpats)
                 self._anypats = self._anypats or _anypats(kindpats)
                 self.patternspat, pm = _buildmatch(ctx, kindpats, '$',
-                                                   listsubrepos)
+                                                   listsubrepos, root)
                 matchfns.append(pm)
 
         if not matchfns:
@@ -450,7 +450,7 @@ def _regex(kind, pat, globsuffix):
         return '.*' + pat
     return _globre(pat) + globsuffix
 
-def _buildmatch(ctx, kindpats, globsuffix, listsubrepos):
+def _buildmatch(ctx, kindpats, globsuffix, listsubrepos, root):
     '''Return regexp string and a matcher function for kindpats.
     globsuffix is appended to the regexp of globs.'''
     fset, kindpats = _expandsets(kindpats, ctx, listsubrepos)


More information about the Mercurial-devel mailing list