[RFC] handling files with weird names in .bzrignore
John Arbash Meinel
john at arbash-meinel.com
Sat May 29 14:11:49 BST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Parth Malwankar wrote:
> Hello,
>
> I started looking into a 'bzr ignore' bug[1] regarding handling
> filenames like "[". When we try to ignore such a file, bzr tries
> to interpret the name as a glob pattern and subsequently
> crashes inside Pythons re module. As the pattern is already
> in the file at this point, Doing 'bzr st' also crashes with the same
> error.
>
> There are at least two ways we could fix this:
>
> (1) Catch the exception and issue an error message indicating
> to the user that the given string is an invalid glob pattern
> and she should consider using "RE:" style python patterns
> and point to "bzr help patterns". "RE:\[" works fine in the case of
> this bug. We would need to ensure patterns are added to
> bzrignore only if they are valid.
>
> (2) The issue here is that there is no good way to represent
> files that have weired names. Going by GNU grep, we could allow
> a -F/--fixed-strings style patterns that would be prefixed with
> say "FS:" in .bzrignore so for this particular bug we would have
> "FS:[". "bzr ignore" would then support a -F/-fixed-string flag.
>
> Now, (1) is easier to implement and doesn't need much
> change. (2) seems to need more work but would probably keep
> non-Python users happy and is arguably the _correct_ fix. But
> then again this issue may be enough of a corner case that (1) is
> fine. There may also be some performance implications.
>
> I on the fence between (1) and (2) and would appreciate any
> suggestions or feedback.
>
> Regards,
> Parth
>
> [1] https://bugs.launchpad.net/bzr/+bug/433437
>
>
What about
(3) Be loose in our handling of globs such that [ with an unmatched ] is
just treated as '['.
Just a thought.
I do think we should trap illegal patterns earlier. Certainly I think
'bzr ignore' could certainly check that it can be turned into a real
pattern matcher, and error before adding it to the ignore list.
There is also
(4) When turning patterns into regexes, anything that is illegal just
gets thrown out with a warning saying that it isn't a legal pattern.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkwBEpQACgkQJdeBCYSNAAOf6gCg2NZaBqluOCjYNo76chOWtvc8
rAkAoL/0MPPq1/sI6nKHZmMqjAWI/IZt
=/+XS
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list