[RFC] handling files with weird names in .bzrignore

Parth Malwankar parth.malwankar at gmail.com
Sat May 29 13:21:42 BST 2010


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



More information about the bazaar mailing list