Looking at case insensitivity - question
Paul Moore
p.f.moore at gmail.com
Sun Apr 13 22:34:39 UTC 2008
On 13/04/2008, Jens Alfke <jens at mooseyard.com> wrote:
> > I can write a function to do this, but I think it needs to be
> > expensive (walk up the filename, doing os.listdir at each level, to
> > get the correct case for the name).
> >
>
> It's possible that on Mac OS X the standard system call realpath will
> upper/lower-case the filename to match what's on disk. I'm not sure, but it
> wouldn't be hard to write a little test program. Then it's a question of
> whether there's a wrapper for realpath in the Python library.
I'm sure there are OS-specific ways of doing this, but I doubt that
the right way to go is with OS-specific code for this (no, there
doesn't seem to be a general wrapper in the Python library :-()
> > 3. Is there a way I can check for a case-sensitive filesystem (I can't
> > just check the system type - think of Windows filesystems mounted on
> > Unix over Samba) to avoid the cost in this case?
> >
[...]
> I believe the best you can do is run some experiments on the filesystem.
> For example, to test case-sensitivity, create a temporary file .hg/xxx and
> then try to read .hg/XXX. (Obviously a robust check will have to be more
> careful than that, but you get the idea.)
I thought that might be the case :-( That's likely to be far too
expensive to do in this context - we're at a case where the current
code does a single stat, as far as I can tell. I'm already exploding
that to a set of directory walks, which is bad enough (hence my
question about performance) but I'm pretty sure that writing and
deleting a temporary file is a non-starter.
Sigh.
Thanks for the comments.
Paul.
More information about the Mercurial
mailing list