Patchwork [5,of,7] match: resolve 'set:' patterns first in _buildmatch()

login
register
mail settings
Submitter Yuya Nishihara
Date July 5, 2018, 2:14 p.m.
Message ID <c81f8e935af38b19a200.1530800070@mimosa>
Download mbox | patch
Permalink /patch/32645/
State New
Headers show

Comments

Yuya Nishihara - July 5, 2018, 2:14 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1528613547 -32400
#      Sun Jun 10 15:52:27 2018 +0900
# Node ID c81f8e935af38b19a2004fb507bcf74783b0db06
# Parent  eca5e10e8949810dc00b01bc84566393bba2bfae
match: resolve 'set:' patterns first in _buildmatch()

This just makes the next patch less complicated. The order of 'set:' and
'subinclude:' expansion doesn't matter.
via Mercurial-devel - July 5, 2018, 6:42 p.m.
On Thu, Jul 5, 2018 at 7:15 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1528613547 -32400
> #      Sun Jun 10 15:52:27 2018 +0900
> # Node ID c81f8e935af38b19a2004fb507bcf74783b0db06
> # Parent  eca5e10e8949810dc00b01bc84566393bba2bfae
> match: resolve 'set:' patterns first in _buildmatch()
>
> This just makes the next patch less complicated. The order of 'set:' and
> 'subinclude:' expansion doesn't matter.
>

How about if you subinclude a file that has a fileset in it? Is that not
possible because 'subinclude:' can only be used in .hgignore files and
'set:' cannot be used there? Or why does the order not matter?
Yuya Nishihara - July 6, 2018, 12:19 p.m.
On Thu, 5 Jul 2018 11:42:05 -0700, Martin von Zweigbergk wrote:
> On Thu, Jul 5, 2018 at 7:15 AM Yuya Nishihara <yuya@tcha.org> wrote:
> 
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1528613547 -32400
> > #      Sun Jun 10 15:52:27 2018 +0900
> > # Node ID c81f8e935af38b19a2004fb507bcf74783b0db06
> > # Parent  eca5e10e8949810dc00b01bc84566393bba2bfae
> > match: resolve 'set:' patterns first in _buildmatch()
> >
> > This just makes the next patch less complicated. The order of 'set:' and
> > 'subinclude:' expansion doesn't matter.
> >
> 
> How about if you subinclude a file that has a fileset in it? Is that not
> possible because 'subinclude:' can only be used in .hgignore files and
> 'set:' cannot be used there? Or why does the order not matter?

The order doesn't matter since _expandsubinclude() does NOT expand subinclude
patterns into the kindpats list. Basically subinclude patterns are fed back to
match.match() as include=['include:<file>']. And the 'include:' doesn't support
'set:' anyway as you mentioned.
via Mercurial-devel - July 6, 2018, 3:02 p.m.
On Fri, Jul 6, 2018 at 5:20 AM Yuya Nishihara <yuya@tcha.org> wrote:

> On Thu, 5 Jul 2018 11:42:05 -0700, Martin von Zweigbergk wrote:
> > On Thu, Jul 5, 2018 at 7:15 AM Yuya Nishihara <yuya@tcha.org> wrote:
> >
> > > # HG changeset patch
> > > # User Yuya Nishihara <yuya@tcha.org>
> > > # Date 1528613547 -32400
> > > #      Sun Jun 10 15:52:27 2018 +0900
> > > # Node ID c81f8e935af38b19a2004fb507bcf74783b0db06
> > > # Parent  eca5e10e8949810dc00b01bc84566393bba2bfae
> > > match: resolve 'set:' patterns first in _buildmatch()
> > >
> > > This just makes the next patch less complicated. The order of 'set:'
> and
> > > 'subinclude:' expansion doesn't matter.
> > >
> >
> > How about if you subinclude a file that has a fileset in it? Is that not
> > possible because 'subinclude:' can only be used in .hgignore files and
> > 'set:' cannot be used there? Or why does the order not matter?
>
> The order doesn't matter since _expandsubinclude() does NOT expand
> subinclude
> patterns into the kindpats list.


Ah, that was what I was missing. Queuing this. Thanks for cleaning up!
Looking forward to the rest.


> Basically subinclude patterns are fed back to
> match.match() as include=['include:<file>']. And the 'include:' doesn't
> support
> 'set:' anyway as you mentioned.
>

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -828,6 +828,10 @@  def _buildmatch(ctx, kindpats, globsuffi
     globsuffix is appended to the regexp of globs.'''
     matchfuncs = []
 
+    fset, kindpats = _expandsets(kindpats, ctx, listsubrepos)
+    if fset:
+        matchfuncs.append(fset.__contains__)
+
     subincludes, kindpats = _expandsubinclude(kindpats, root)
     if subincludes:
         submatchers = {}
@@ -844,10 +848,6 @@  def _buildmatch(ctx, kindpats, globsuffi
             return False
         matchfuncs.append(matchsubinclude)
 
-    fset, kindpats = _expandsets(kindpats, ctx, listsubrepos)
-    if fset:
-        matchfuncs.append(fset.__contains__)
-
     regex = ''
     if kindpats:
         regex, mf = _buildregexmatch(kindpats, globsuffix)