[PATCH 3 of 4] match: enable 'relinclude:' syntax

Durham Goode durham at fb.com
Thu May 21 21:34:34 CDT 2015



On 5/21/15 11:20 AM, Martin von Zweigbergk wrote:
>
>
> On Thu, May 21, 2015 at 11:11 AM Martin von Zweigbergk 
> <martinvonz at google.com <mailto:martinvonz at google.com>> wrote:
>
>     On Wed, May 20, 2015 at 3:01 PM Durham Goode <durham at fb.com
>     <mailto:durham at fb.com>> wrote:
>
>         # HG changeset patch
>         # User Durham Goode <durham at fb.com <mailto:durham at fb.com>>
>         # Date 1431818705 25200
>         #      Sat May 16 16:25:05 2015 -0700
>         # Node ID 3bbfdda372e8e4204a5440009bfbc9e81f2a93e9
>         # Parent  28ac58249dbc906622e368357daadd4814f9c71c
>         match: enable 'relinclude:' syntax
>
>         This adds a new rule syntax that allows the user to include a
>         pattern file, but
>         only have those patterns match against files underneath the
>         subdirectory of the
>         pattern file.
>
>         This is useful when you have nested projects in a repository
>         and the inner
>         projects wants to set up ignore rules that won't affect other
>         projects in the
>         repository. It is also useful in high commit rate repositories
>         for removing the
>         root .hgignore as a point of contention.
>
>         diff --git a/mercurial/match.py b/mercurial/match.py
>         --- a/mercurial/match.py
>         +++ b/mercurial/match.py
>         @@ -5,7 +5,7 @@
>          # This software may be used and distributed according to the
>         terms of the
>          # GNU General Public License version 2 or any later version.
>
>         -import re
>         +import os, re
>          import util, pathutil
>          from i18n import _
>
>         @@ -42,6 +42,25 @@ def _expandsets(kindpats, ctx, listsubre
>                  other.append((kind, pat, source))
>              return fset, other
>
>         +def _expandsubinclude(kindpats, root):
>         +    '''Returns the list of subinclude matchers and the
>         kindpats without the
>         +    subincludes in it.'''
>         +    relmatchers = []
>         +    other = []
>         +
>         +    for kind, pat, source in kindpats:
>         +        if kind == 'subinclude':
>         +            sourceroot = os.path.dirname(source)
>         +            path = os.path.join(sourceroot, pat)
>         +            newroot = os.path.dirname(path)
>         +            relmatcher = match(newroot, '', [], ['include:%s'
>         % path])
>
>
> What will the "bad" message say? Will it be relative to newroot? Is it 
> easy to add a test for that too?
Bad is not actually called by the matcher.  It is only set and executed 
by external callers, so we don't actually need to worry about it for 
sub-matchers since external callers will only be dealing with the top 
level matcher.

That said, this is the first time I've looked at the 'bad' function on 
match, and it's a pretty terrible hack :/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150521/498a98c4/attachment.html>


More information about the Mercurial-devel mailing list