[PATCH 1 of 3] Add a new function, filesystem_case
Paul Moore
p.f.moore at gmail.com
Sat Apr 26 13:10:05 UTC 2008
2008/4/23 Paul Moore <p.f.moore at gmail.com>:
> 2008/4/23 Matt Mackall <mpm at selenic.com>:
> > Second, this problem isn't at all localized to Windows, so localizing
> > the solution to Windows is getting off on the wrong foot. Just define
> > the function everywhere and then use checkfolding to decide whether or
> > not to /use/ it.
>
> That sounds fair.
There's a bit of a problem here, as I use fspath on the elements of
the files argument to dirstate.statwalk. This is the user-supplied
list of files, and as such can contain arbitrary file names. I'm OK as
long as the file has a foldable leaf part, as then I can use
checkfolding to determine whether I need fspath (I'm assuming that a
checkfolding call for every element of files is not too much overhead
on case-sensitive Unix systems, as that's the added cost of this
method). However, if the user supplies a filename like 'a/1234' then
checkfolding won't work on it, and yet the filesystem may have the
directory name as "A". (This type of filename comes up in the test
suite, so it's not entirely a theoretical issue).
Hmm, one fix would be to make checkfolding fold the case of the whole pathname:
def checkfolding(path):
s1 = os.stat(path)
p2 = path.upper()
if path == p2:
p2 = path.lower()
try:
s2 = os.stat(p2)
if s2 == s1:
return False
return True
except:
return True
Then checkfolding works as long as any part of the path is foldable,
and for my purposes if the whole path is non-foldable, then I don't
care anyway.
I can't see a downside to this - does it look OK?
Thanks,
Paul.
More information about the Mercurial-devel
mailing list