[PATCH] Allow manipulating files with long names on Windows

Sune Foldager cryo at cyanite.org
Tue Jan 25 03:17:19 CST 2011


On 20-01-2011 18:02, Aaron Cohen wrote:
> # HG changeset patch
> # User Aaron Cohen<aaron at assonance.org>
> # Date 1295249042 18000
> # Node ID 6e72a5a75afc05927a9ee083d6c89450e1b5cc1f
> # Parent  9f707b297b0f52278acc6c4a4f7c6d801001acb7
> Allow manipulating files with long names on Windows
>
> Windows by default has a MAX_PATH of 260 characters. A while ago the
> "fncache" format was added which allows repositories on Windows to
> contain very long paths. At the time, a patch was proposed,
> "longpath.patch" which enabled handling of those files in the working
> copy but it was tabled.
>
>  From http://mercurial.selenic.com/bts/issue839, I infer that the
> reason for this is that many tools on Windows don't handle long file
> names gracefully. Time has passed though and more programs now work,
> including all Java programs.

...but excluding all Windows' built-in tools such as Explorer, cmd.exe, 
PowerShell.exe, compression and so on. In practice, I find it 
intolerable, as you need specialized tools for any work you need to do 
with files like these.

If Microsoft would fix their damn tools, it would be a different story :)

> + - cmd.exe has trouble manipulating long pathnames (del, move, rename will all
> +    fail). Use powershell.

In PowerShell:

C:\ $ mkdir ('\lalalalalalalalalalalalalalalalalalala' * 20)
New-Item : The specified path, file name, or both are too long. The 
fully qualified file name must be less than 260 characters, and the dir
ectory name must be less than 248 characters.

You may be able to list directories and such, but you can't do a lot of 
other things.

> + - Many legacy Windows programs will have difficulty opening files with long
> +    pathnames, though most java and 64-bit programs will work fine.

Because opening with long file names is a different API... Explorer, cmd 
and PowerShell are all 64-bit as well... dammit Microsoft!

> + - explorer.exe may have trouble manipulating directories with long paths,
> +    with dialogs like, "The source file name(s) are larger than is supported
> +    by the file system. Try moving to a location which has a shorter path name."
> +    To address this, use a tool other than explorer.exe or delete the affected
> +    files using :hg:`lfn clean`.

TL;DR: Explorer.exe CAN'T manipulate [...] long paths. Seriously, there 
is no need to sugar it up :-p. You can't even trash a file with a long name.

Oh well, as long as it's an extension :)
/Sune


More information about the Mercurial-devel mailing list