[issue839] Hg local store creates paths too long for Windows

Jesse Glick mercurial-bugs at selenic.com
Wed Nov 21 11:11:29 CST 2007

New submission from Jesse Glick <jesse.glick at sun.com>:

A Mercurial local repository storage escapes capital letters for safety on
Windows, which is good and necessary. However certain file paths which are
already too long in the checkout become even longer in the local repository,
making it impossible to use the repository on Windows, which seems to have about
a 260 character maximum. (For example, a tarball of the repository cannot even
be unpacked on Windows.)

The exact maximum is of course dependent on the length of the path of the root
directory of the repository, but I would say that above around 180 characters
for an in-repository path is dangerous.

Example encountered when trying to create a Hg repo based on an existing source
tree (in CVS, but not using convert extension, just an import of trunk):


(180 chars) becomes


(216 chars) which is bound to cause troubles even where CVS worked.

Obviously it would be wise for the developer to reduce the length of the actual
file path. But I think Hg should also have some cutoff for the length of paths
it will create in the repository, say 150 by default but configurable. It
already does some name mangling for case sensitivity, so why not truncate some
path components to make the final path shorter?

(My understanding, which could be mistaken, is that paths in the .hg/store/data/
directory are arbitrary, since the manifest anyway maps real file paths in the
checkout to storage paths; and that Hg just uses storage paths derived from the
real paths as a debugging aid. It is not obvious from code comments whether
localrepo.py automatically manages conflicts between storage paths, but probably
not - '_' is escaped to '__' I guess to prevent such conflicts. In such a case,
simple truncation would be unsafe. But you could still truncate paths safely
using e.g. an unabbreviated SHA-1 hash for 40 chars plus most of the normal
filename for the remaining chars. I guess this would live in

I have seen issue #584. I have tried

---%<--- .hg/hgrc

though it does not seem to have any effect (hg 0.9.5). Anyway the Windows case
mangling is necessary for safety (my team has encountered the analogous problems
with CVS a number of times in the past) and I would not want this to be turned off.

messages: 4352
nosy: jglick
priority: bug
status: unread
title: Hg local store creates paths too long for Windows
topic: windows

Mercurial issue tracker <mercurial-bugs at selenic.com>

More information about the Mercurial-devel mailing list