[PATCH] [RFC] Add an extension allowing the working copy to contain very long filenames on Windows

Adrian Buehlmann adrian at cadifra.com
Sat Jan 15 18:29:51 CST 2011


On 2011-01-16 01:08, Adrian Buehlmann wrote:
> On 2011-01-13 22:46, Aaron Cohen wrote:
>> On Wed, Jan 12, 2011 at 5:49 PM, Adrian Buehlmann <adrian at cadifra.com> wrote:
>>> On 2011-01-12 22:41, Aaron Cohen wrote:
>>>> Hi all,
>>>>
>>>>   I apologize that I've attached this patch, but I'm unable to send
>>>> using patchbomb due to our mailserver configuration.
>>>>
>>>
>>> I'm pasting your patch inline below
>>>
>>>> # HG changeset patch
>>
>> Thank you for your review! I've made fixes locally and was going to
>> resend, but I also added some test cases and in so doing, ran into a
>> problem. It seems the repository I've been testing with has files
>> whose total path length was greater than 260, which was what caused my
>> initial problem. However, none of the files has a directory portion of
>> the path longer than 260 (248 actually).
>>
>> I made a testcase that tried to make a 260-character-deep directory
>> tree, and os.listdir bombs out whether or not I give it a UNC path.
>>
>> I'm still pursuing alternatives. I may have to look into using win32
>> api functions directly. Is it alright for an extension in hgext to
>> have a dependency the python pywin32 extensions?
>>
>> Without this fixed, I'm not sure how generally-applicable my extension
>> is. It's kind of weird to say, "This extension allows very long
>> filenames on windows, unless the directory portion of those filenames
>> is too long".
> 
> This reminds me of the fact that Mercurial has it's own implementation/
> replacement for Python's (slow) os.listdir, implemented in C in
> osutil.listdir, which is limited to PATH_MAX path length (260) for the
> Windows platform (see osutil.c, line 281).

Sorry, I spoke too soon and you might be lucky: I'm wrong because
PATH_MAX is defined as (in osutil.c):

#ifndef PATH_MAX
#define PATH_MAX 4096
#endif

and is indeed not already defined when compiling for the Windows
platform (I confused it with Windows' MAX_PATH, which is 260).

> See also the implementation of walk() in dirstate.py for an example
> usage of osutil.listdir (line 565).
> 
> How do you intend to work around that?

But osutil.listdir probably still needs a closer look. If it turns out
that it actually -can- handle UNC paths, then you might use that instead
of Python's os.listdir.


More information about the Mercurial-devel mailing list