Patchwork [1,of,4] match: add root to _buildmatch

login
register
mail settings
Submitter Durham Goode
Date May 20, 2015, 9:57 p.m.
Message ID <aed26cd32a07f5e18065.1432159053@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/9199/
State Accepted
Commit 5a55ad6e8e241c78156389b864a7199ead080e71
Headers show

Comments

Durham Goode - May 20, 2015, 9:57 p.m.
# HG changeset patch
# User Durham Goode <durham@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.

Patch

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)