[PATCH][MERGE] Improvements to is_ignored

John Arbash Meinel john at arbash-meinel.com
Wed Jan 11 21:30:01 GMT 2006


Harald Meland wrote:
> [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.)
> 

Only slightly. Any explicitly added file will never be ignored. ignored
is simply a statement that 'this file is unknown, I want you to ignore it'.

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

I agree. Especially because we might need to utf-8 encode the path, I
would tend to recommend bzr ignore all the time. And we should (possibly
with an error message) change backslashes to forward slashes.
(Internally we are trying to make all paths forward slashes anyway.)

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060111/98fd99f2/attachment.pgp 


More information about the bazaar mailing list