[PATCH 2 of 2] dirstate: normalize on case insensitive filesystems on Mac (issue1663)
adrian at cadifra.com
Thu Jul 23 11:49:56 CDT 2009
On 23.07.2009 17:14, Matt Mackall wrote:
> On Thu, 2009-07-23 at 12:08 +0200, Simon Heimberg wrote:
>> Am Mittwoch, den 22.07.2009, 14:04 -0500 schrieb Matt Mackall:
>>> On Wed, 2009-07-22 at 15:22 +0200, Simon Heimberg wrote:
>>>> # HG changeset patch
>>>> # User Simon Heimberg <simohe at besonet.ch>
>>>> # Date 1248264291 -7200
>>>> # Node ID f812e62a12b68c035b1aef3b3732f8486c376373
>>>> # Parent ca876099803a9e71497d9deaee3c9fb7ff47ee81
>>>> dirstate: normalize on case insensitive filesystems on Mac (issue1663)
>>>> os.path.normcase does not change the path on Mac OS X (uses possix module)
>>>> diff -r ca876099803a -r f812e62a12b6 mercurial/dirstate.py
>>>> --- a/mercurial/dirstate.py Mit Jul 22 12:52:02 2009 +0200
>>>> +++ b/mercurial/dirstate.py Mit Jul 22 14:04:51 2009 +0200
>>>> @@ -351,8 +351,14 @@
>>>> except KeyError:
>>>> self._ui.warn(_("not in dirstate: %s\n") % f)
>>>> + _usenormcase = os.path.normcase("A") == "a"
>>>> def _normalize(self, path, knownpath):
>>>> - norm_path = os.path.normcase(path)
>>>> + if self._usenormcase:
>>>> + norm_path = os.path.normcase(path)
>>>> + else:
>>>> + #case insensitive filesystem on Mac OS X
>>>> + norm_path = path.lower()
>>> You're going to have to be more clever than lower(), I'm afraid.
>>> Consider a file named 'Ä' and the possibility that your local character
>>> set might be set to MacRoman. There's also the whole issue of Unicode
>> This is as clever as os.path.normcase in windows and mac (not OS X) (see
>> ntpath.py and macpath.py from python). We could use macpath.normcase for
>> being upgraded when python is.
>>> I think we need to have a more general facility for dealing with all
>>> forms of folding (ie any non-direct filename matching/mangling) that
>>> allows us to deal with all the stupid Windowsisms and Macisms.
>>> Case-folding is just the most commonplace form of it.
>> Maybe this could happen too on linux or unix when a special file system
>> is mounted or with some mount options.
>> More general is good, but I do not have an idea how to do it. Any hint?
>> What are other cases of folding?
> foo. -> foo
> (there might be some magic with trailing spaces too)
"Basic Naming Conventions
The following fundamental rules enable applications to create and process valid
names for files and directories, regardless of the file system:
Do not end a file or directory name with a trailing space or a period. Although
the underlying file system may support such names, the operating system does not.
Not sure if that can be subsumed under "folding" or "mangling".
Maybe file names ending in period or space(s) should be treated as not
being valid names for files on Windows. That is, Mercurial should probably
not try writing or accepting such names and maybe abort (on Windows).
Aside: stupid explorer of vista and Windows 7 strips spaces from
beginning of file names when copying files -- even though such names
are valid according to  (as noted in issue1713).
More information about the Mercurial-devel