[RFC] handling files with weird names in .bzrignore

Stefan Monnier monnier at iro.umontreal.ca
Sat May 29 23:49:26 BST 2010


>> (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.

That would be good, but not sufficient because the .bzrignore may be
edited by hand.

>> (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.

Feeping creaturism.  Why not just add a --noglob argument to "bzr
ignore" which will then turn the pattern into an "RE:" pattern with the
needed escaping?

>> 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

Doesn't look like "the correct fix" to me, because it won't be
sufficient for filenames [*.  And since we already have regexps to
handle the general case, there's no good reason not to use them.

> (3) Be loose in our handling of globs such that [ with an unmatched ] is
> just treated as '['.

Bad idea.  We do/did this kind of thing a lot in Emacs, and we always
end up regretting it later.

> (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.

Yes: that's really the only solution that's possible, reliable, and safe.


        Stefan




More information about the bazaar mailing list