[PATCH] ignore: add case-insensitive globs support

Martin Geisler mg at aragost.com
Wed Mar 30 09:06:19 CDT 2011


Eduard-Cristian Stefan <alexandrul.ct at gmail.com> writes:

Hi Eduard,

You should send patches to mercurial-devel -- I've Cc'ed that list.

> # HG changeset patch
> # User Eduard-Cristian Stefan <alexandrul.ct at gmail.com>
> # Date 1301485719 -10800
> # Node ID c1798f1bc9a7f1633f4d0e755a433e9d77ac1e62
> # Parent  307c72686eb0c336db0e20143a76edb211e9bba8
> ignore: add case-insensitive globs support

I like this idea.

> -def _globre(pat):
> +def _globre(pat, ci=False):

The argument name could be better, I would never have guessed that 'ci'
means 'case-insensitive' if I hadn't seen this patch.

>      "convert a glob pattern into a regexp"
>      i, n = 0, len(pat)
> -    res = ''
> +    res = ['', '(?i)'][ci]

Please use a real if-statement here -- it took me three attempts to
figure out what was going on here :)

>      group = 0
>      escape = re.escape
>      def peek():
> @@ -232,6 +234,8 @@
>          return '^' + re.escape(name) + '(?:/|$)'
>      elif kind == 'relglob':
>          return '(?:|.*/)' + _globre(name) + tail
> +    elif kind == 'religlob':
> +        return '(?:|.*/)' + _globre(name, ci=True) + tail
>      elif kind == 'relpath':
>          return re.escape(name) + '(?:/|$)'
>      elif kind == 'relre':
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://aragost.com/en/services/mercurial/blog/


More information about the Mercurial-devel mailing list