[PATCH 2 of 2] dirstate: normalize on case insensitive filesystems on Mac (issue1663)

Dan Villiom Podlaski Christiansen danchr at gmail.com
Fri Jul 24 15:39:43 CDT 2009

On 24/07/2009, at 21.44, Matt Mackall wrote:

> Posix it ain't. It might be time for a mac.py.

Indeed; might I suggest the name macosx.py instead? :)

> Have you considered unicodedata.normalize("NFD", f).lower()?

I haven't actually, as I wasn't aware of that module :)

(One question, though: Would the ‘X.lower()’ trick mean that only  
lowercase names are shown to the user? If so, I really don't like it  
from a user interface perspective…)

Unfortunately, the issue is slightly more complex than that; the  
normalisation required for HFS+ doesn't correspond to any standard  
Unicode normalisation. It might be better to simply implement the  
normalisation ourselves, based on the HFS volume format specification. 
[1] One thing though; not all volumes on Mac OS X are case  
independent, but I suspect the Unicode normalisation is universal.  
(I'd have to dig much deeper into documentation, references & source  
to be certain.)

I just noticed some issues with my Carbon round-trip, though: First,  
the initial patch causes suppression of all unknown files. Second, it  
doesn't work at all for symbolic links:

>> % ln -sf /tmp xxx
>> % python2.4
>> ...
>> >>> from Carbon.File import FSPathMakeRef
>> >>> FSPathMakeRef('xxx')[0].as_pathname()
>> '/private/tmp'

> (there are other hairy issues here, like filenames in Latin1)

That issue should be ‘solved’ rather simply on Mac OS X, I believe: by  
definition, such file names cannot exist, ever. I remember mounting an  
NTFS volume once that used some non-UTF-8 encoding for its file names;  
whether GUI or CLI, the system *really* doesn't like such file names.

[1] <http://developer.apple.com/technotes/tn/tn1150.html#UnicodeSubtleties 


Dan Villiom Podlaski Christiansen
danchr at gmail.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1943 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090724/843f5709/attachment.bin 

More information about the Mercurial-devel mailing list