glob instead of regexp (was: Re: [PATCH 0 of 4] Add locate command)

Thomas Arendsen Hein thomas at intevation.de
Tue Jul 12 21:10:50 UTC 2005


* Bryan O'Sullivan <bos at serpentine.com> [20050712 22:45]:
> On Tue, 2005-07-12 at 21:11 +0200, Thomas Arendsen Hein wrote:
> 
> > I suggest:
> > /foo matches from the repo root
> > foo matches anywhere
> > foo/ matches directory foo
> > *?[ works like in the shell: stop at slashes, quoted with \
> 
> I don't much like the /foo idea, because it's prone to overloading "root
> of repository" with "root of filesystem", but I can't think of any
> better suggestions.  Perforce uses // instead of / to denote the
> repository root, which is at least visually different.

This overloading is done everywhere, just look at http URLs, there
you don't need http://server//foo to get foo from the root
directory, too.

> I definitely don't like an unrooted foo as matching anywhere, as that's
> just asking for trouble ("I wanted to exclude just this doc directory,
> but I lost all the other ones, too!").  Other tools that support
> include/exclude notions (e.g. find -path, rsync -include) don't behave
> this way.

find is complicated, I don't want Mercurial to use it's notation,
though it is very flexible and has its uses.

rsync behaves exactly like I proposed above, except that it has the
additional ** wildcard. The term "anywhere" is really somewhat
misleading, I should be: foo matches /foo and /bar/foo, but not
/foobar or /bar/foobie or /bar/foo/bletch

> > One could add that every pattern that starts with ^ is a regexp,
> > just in case someone needs really odd patterns.
> 
> That's a nice idea.  That saves us the bother of adding new options to
> distinguish between regexps and globs.

Yes, and this way we don't need a .hgglobignore and .hgregexpignore :)

Thomas

-- 
Email: thomas at intevation.de
http://intevation.de/~thomas/



More information about the Mercurial mailing list