Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Steve Hollasch <stevehol <at> microsoft.com>
Subject: RE: Trying to Figure Out .hgignore Patterns
Newsgroups: gmane.comp.version-control.mercurial.general
Date: Thursday 16th September 2010 00:21:50 UTC (over 7 years ago)
The issue here isn't the regular expression per se, it's the way that
Mercurial interprets the ^ and $ tokens. In the case below, the meat of the
expression is the fixed string "foo". The problem is that ^ matches the
beginning of the path, while $ matches the end of any subdirectory. So, for
example, if Mercurial interpreted '$' as the end of the path, I could
reliably target leaves by ending the pattern with a '$'. Indeed, that's
what a standard regular expression match would yield (such as the tool you
mention below). However, the problem with Mercurial is that it doesn't seem
to perform a true regular expression match, but instead iterates across
multiple paths of successive depth.

For example, if the relative path of a given target is "xyz/foo/foox", and
the pattern is "foo$", then the following matches will be tested:

	"foo$" in "xyz" (false)
	"foo$" in "xyz/foo" (true)
	"foo$" in "xyz/foo/foox" (false)

Since the target strings change only in their endings, '^' is consistent
from match to match, while '$' is not. Thus, one cannot reliably match
against leaves in a path.



-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Andrew J.
Leer
Sent: Wednesday, 15 Sep 2010 17:09
To: Steve Hollasch
Subject: Re: Trying to Figure Out .hgignore Patterns

Use one of the many online Regular Expression Testing tools to figure it
out first:

http://www.gskinner.com/RegExr/
http://regexpal.com/

On Wed, Sep 15, 2010 at 8:00 PM, Steve Hollasch 
wrote:
> I'm having a heck of a time trying to get simple file patterns to work in
my .hgignore file. Suppose I want to ignore all files named "foo", and I
have the following in my directory:
>
>      * foo
>        foox
>        xfoo
>      * xyy/foo
>        xyy/foox
>        xyy/xfoo
>      * xyz/foo/foo
>        xyz/foo/foox
>        xyz/foo/xfoo
>      * xyz/foox/foo
>        xyz/foox/foox
>        xyz/foox/xfoo
>      * xyz/xfoo/foo
>        xyz/xfoo/foox
>        xyz/xfoo/xfoo
>
> Is there a syntax that will allow me to match this? I can't find any rule
or set of rules that will yield this pattern. Here are things I've tried:
>
> glob "foo"
>        Matches directories named "foo". File globs don't appear to 
> have anything
>        that would prevent matches on files with a same-named 
> subdirectory in their
>        path.
>
> regexp "/foo$"
>        Oddly enough, the terminator $ matches against interior '/'
characters.
>        Thus, this pattern matches "xyz/foo/foox".
>
> I've read the man page as well as the wiki entry, but I'm just not
getting it. Surely there's a way to do this, isn't there?
>
> I wish Mercurial supported ellipsis-style path matching; I believe
Perforce uses this for depot specifications. Then the pattern would be a
simple ".../foo", and it would just work.
>
> Anyway, am I missing something here? Ignore pattern matching seems very
clumsy otherwise.
> _______________________________________________
> Mercurial mailing list
> [email protected]
> http://selenic.com/mailman/listinfo/mercurial
>
 
CD: 3ms