[PATCH] ignore: add case-insensitive globs support
Matt Mackall
mpm at selenic.com
Wed Mar 30 17:45:56 UTC 2011
On Wed, 2011-03-30 at 20:19 +0300, Eduard-Cristian Stefan wrote:
> On 2011-03-30 16:21, Matt Mackall wrote:
> > On Wed, 2011-03-30 at 14:50 +0300, Eduard-Cristian Stefan wrote:
> >> ignore: add case-insensitive globs support
> > [...]
> >> -def _globre(pat):
> >> +def _globre(pat, ci=False):
> >> "convert a glob pattern into a regexp"
> >> i, n = 0, len(pat)
> >> - res = ''
> >> + res = ['', '(?i)'][ci]
> >> group = 0
> >> escape = re.escape
> >> def peek():
> >
> > I'm afraid this won't work. It will make -all- ignore patterns case
> > insensitive. We join all the regexes into a single expression for
> > performance and the flag is global.
>
> You are right, but I think I've found a bug. In an empty repo,
> for this list of files:
>
> 1.bak
> 2.BaK
> 3.log
> 4.LoG
> 5.res
> 6.ReS
> 7.txt
> 8.TxT
>
> if .hgignore contains:
>
> syntax: glob
> *.bak
>
> syntax: regexp
> ^.*\.res$
> ^.*\.txt$
>
> then hg status returns as expected:
>
> ? .hgignore
> ? 2.BaK
> ? 3.log
> ? 4.LoG
> ? 6.ReS
> ? 8.TxT
>
> But if I modify .hgignore to ignore *.txt case-insensitive:
>
> syntax: glob
> *.bak
>
> syntax: regexp
> ^.*\.res$
> (?i)^.*\.txt$
>
> then hg status seems to treat all ignore patterns as case-insensitive:
>
> ? .hgignore
> ? 3.log
> ? 4.LoG
>
> OTOH, if this behavior is by design, then simply adding a line like:
>
> syntax: regexp
> (?i)^nonexistentfile$
Yep, setting any of the (?x) flags in any pattern will have a global
effect across patterns. In general, doing "clever" things with ignore
regexes probably won't do what you want.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list