[PATCH 1 of 3] Add a new function, filesystem_case

Paul Moore p.f.moore at gmail.com
Wed Apr 23 16:57:56 CDT 2008


2008/4/23 Patrick Mézard <pmezard at gmail.com>:

>  > +    def filesystem_case(name, root=''):
>
>  We usually try to avoid long identifiers and underscores. What about "fspath()" ? It would also fit for a normalizing
> version on OSX.

Good suggestion. Naming never was my strong point :-)

>  > +        if not os.path.exists(os.path.join(root, name)):
>  > +            return name
>
>  Maybe we can have a fallback value instead (defaulting to None). That would shave one os.path.exists() call in the
> third patch.

I'll look at this. Anything to keep the cost down - the whole function
feels awfully expensive :-(

>  I have no numbers to backup my claims but that really looks expensive to deal with a single file. At least, we
> should have a much faster version in util_win32, as suggested by Alexander Belchenko.

That's my big concern, too. The problem with Alexander's suggestion (I
tried it) is that win32api.FindFiles only works on the leaf name, so
you end up having to do all the directory recursion yourself in any
case. The end result was that the generic version wasn't really any
cheaper (in lines of code, at least - like you, I don't have hard
timing numbers to back this up).

>  But the approach is good IMHO, let other comment on this.

Thanks. It's reassuring to hear that. The thing that most nags me
about it is the "tactical" approach - fixing individual problems on a
case by case basis. But I don't think it's practical to try to root
out all the places in the code where case sensitivity is assumed (even
simple equality tests on filename strings may be wrong, if it's a
context where case may vary).

Paul.



More information about the Mercurial-devel mailing list