[PATCH] match: adding non-recursive directory matching

Yuya Nishihara yuya at tcha.org
Tue Oct 18 09:38:23 EDT 2016


On Tue, 18 Oct 2016 09:07:36 -0400, Augie Fackler wrote:
> On Tue, Oct 18, 2016 at 02:46:52PM +0200, Pierre-Yves David wrote:
> > On 10/18/2016 02:25 AM, Augie Fackler wrote:
> > >On Sun, Oct 16, 2016 at 03:50:10PM +0200, Pierre-Yves David wrote:
> > >>
> > >>
> > >>On 10/08/2016 06:58 PM, Rodrigo Damazio Bovendorp via Mercurial-devel wrote:
> > >>># HG changeset patch
> > >>># User Rodrigo Damazio Bovendorp <rdamazio at google.com>
> > >>># Date 1475944120 25200
> > >>>#      Sat Oct 08 09:28:40 2016 -0700
> > >>># Node ID 545efe5a72efdce925a6a3fd3774b350c90b5c55
> > >>># Parent  dbcef8918bbdd8a64d9f79a37bcfa284a26f3a39
> > >>>match: adding non-recursive directory matching
> > >>>
> > >>>This allows one to match all files in a directory, without matching anything in subdirectories.
> > >>>It's implemented almost identically to path:, except for the regex termination, which doesn't
> > >>>allow more than one / after the directory name.
> > >>>
> > >>>diff --git a/mercurial/match.py b/mercurial/match.py
> > >>>--- a/mercurial/match.py
> > >>>+++ b/mercurial/match.py
> > >>>@@ -105,6 +105,9 @@
> > >>>         'glob:<glob>' - a glob relative to cwd
> > >>>         're:<regexp>' - a regular expression
> > >>>         'path:<path>' - a path relative to repository root
> > >>>+        'files:<path>' - a path relative to repository root, which is matched
> > >>>+                         non-recursively (files inside the directory will match,
> > >>>+                         but subdirectories and files in them won't
> > >>
> > >>The feature seems useful and we should have it.
> > >>
> > >>The current behavior is a bit strange to me. because we have directory being
> > >>implicitly recursed of just 1 level (directory content). Could we have a
> > >>xxx:<path> where path is never recursed for anything. Listing a directory
> > >>content would be an explicite 'xxx:my/directory/path/*'
> > >>
> > >>We could use 'exact' or 'norecursion' for xxx.
> > >
> > >exact: works for me. I think norecusion: is too long, since users will
> > >need to type this.
> >
> > What about my proposal of changing the semantic to be plain exact matching
> > (no implicit matching of files in a matched directory) ?
> >
> > That would move use to:
> >
> >
> >         'files:<path>' - a path relative to repository root, which is
> >                          matched non-recursively
> >
> >   exact:foo → match a file 'foo',
> >   exact:foo/* → match content of 'foo' directory,
> >   exact:foo/** → match anything under 'foo',
> 
> After coordinating on irc to figure out what this proposal actually
> is, I've noticed that the semantics of this "exact" proposal are
> exactly what "glob" does today, which means (I think) that
> "files:foo/bar" should be representable as "glob:foo/bar/*" - what am
> I missing?

Maybe we want a "glob" relative to the repo root?


More information about the Mercurial-devel mailing list