[PATCH][MERGE] Improvements to is_ignored
Harald Meland
harald.meland at usit.uio.no
Wed Jan 11 15:35:20 GMT 2006
[John Arbash Meinel]
> I would also do a check for:
> if '\\' in pat:
> pat = pat.replace('\\', '/')
>
> Because I do believe the file paths have been normalized. (fnmatch might
> translate it correctly, but I don't think it does).
I think it is quite rare to have Unix filenames contain literal
backslashes -- but it is possible.
Doing the \-to-/ replacement as suggested above would preclude such
filenames from being ignored.
(You could resort to using e.g. '?' wildcards wherever the literal
backslashes occur, but then you'd have to take care to not make the
wildcard match more files than you want.)
On the other hand, if backslash-containing patterns are interpreted
literally, care will have to be taken to avoid having the patterns
mean different things on Unix and Windows; i.e. the pattern
foo\bar
should, under literal interpretation, *always* be regarded as "match
on any single-path-segment == 'foo\bar'". Even though such a
single-path-segment isn't possible to create on Windows, the pattern
should *not* match on a file 'bar' inside a directory 'foo'.
There could be some tension with the idiom "echo pattern >>
.bzrignore" here; if this idiom is used on Windows, users would be
likely to say "echo foo\bar >> .bzrignore" (or the windows shell
equivalent) when they mean "Ignore the file 'bar' inside the 'foo'
directory". However, I suspect this idiom is rather Unixy -- most
users will rather use "bzr ignore foo\bar", which should do the right
thing on all OSes.
--
Harald
More information about the bazaar
mailing list