Update fails with long file name

Adrian Buehlmann adrian at cadifra.com
Wed Sep 30 09:07:25 UTC 2015


On 2015-09-29 23:22, Benjamin Fritz wrote:
> I think the error given for long file names could be much better. When I
> test adding such a file I just get "{filename} does not exist!" That's
> not very nice. Better would be "File name '{filename}' is too long for
> Windows"; even nicer on Windows would be to distribute the win32lfn
> plugin and give a helpful pointer to it in this situation. I'm not sure
> how hard that would be or whether there is any precedent in Mercurial;
> I'm mostly thinking of times I've tried to run a command in Ubuntu and
> have been pointed at the package that would give me that missing command.

Yes. Maybe the error message could be improved if anybody who cares
enough wants to hack on this.

See https://www.mercurial-scm.org/wiki/DeveloperInfo

Playing with this on the low-level side of things looks, for example, like
this:

$ cd
C:\Users\adi\hgrepos\hg-main

$ python
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from mercurial import windows
>>> s = 'x' * 300
>>> f = windows.posixfile(s, mode='w')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mercurial\windows.py", line 114, in posixfile
    raise IOError(err.errno, '%s: %s' % (name, err.strerror))
IOError: [Errno 2] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: The system cannot find the path specified
>>> import errno
>>> errno.ENOENT
2
>>> import os
>>> os.strerror(2)
'No such file or directory'

Which means, the lower layers treat such attempts to create files with paths that are
too long as ENOENT (No such file or directory).

Function workingctx.add (line 1383 in context.py) appears to do:

                try:
                    st = lstat(f)
                except OSError:
                    ui.warn(_("%s does not exist!\n") % join(f))

Assuming this is what is executed: Telling the user that the file "does not exit", if
it in fact has a too long name, is perhaps not exactly helpful.

See also util.checkwinfilename and its callers for how AUX and friends are treated.




More information about the Mercurial mailing list