Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial: Commit files with more than 255 characters path length (Windows)?

I try to commit a folder hierarchy into out Mercurial repository, which contains files, whiches absolute path length exceeds 255 characters (Windows max. path length).

For these files I receive an error message saying

The system cannot find the path specified

We use TortoiseHG and an Eclipse plugin for Mercurial, both don't work.

Has anybody found a solution for this? (I do not want to change the repository's location on my HD)

like image 600
Windwalker Avatar asked May 25 '12 11:05

Windwalker


People also ask

What is 260 character max path limitation?

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character.


2 Answers

There exists an extension which is aimed at solving this exact problem. It is: https://www.mercurial-scm.org/wiki/Win32LongFileNamesExtension

It uses \\?\ style names to transparently handle long files.

I'm the author, let me know if it works for you.

like image 146
Aaron Cohen Avatar answered Sep 19 '22 14:09

Aaron Cohen


I've just installed Aaron Cohen' extension, as he suggested. And it perfectly works with my TortoiseHG 2.6.1 ! Thanks, Aaron!

Though, I'd like to add a detailed guide here, because I cannot find one...

(At least here's what I did on my Win7 x64 - I'm not sure this is the shortest way possible)

1. Download Mercurial-py

  • Note the Python version required
  • I've downloaded "Mercurial-2.4.2 (64-bit py2.7)"

2. Download Python

  • Make sure you're downloading compatible version.
  • I used "Windows X86-64 MSI Installer (2.7.3)" link

3. Install Python

  • I've installed it to "D:\Python27"

4. Download pywin32

  • It's required by the Win32LongFileNamesExtension.
  • Note the Python version number in pywin32's filename.
  • I used "pywin32-218.win32-py2.7.exe"

5. Install pywin32

  • Make sure installer detected correct Python installation
  • In my case, it's installed in "d:\Python27\Lib\site-packages\pywin32_system32\"

6. Install Mercurial

  • Make sure installer detected correct Python installation
  • In my case, it's installed in "d:\Python27\Lib\site-packages\mercurial\"

7. Set PYTHONPATH enviroment variable

setx PYTHONPATH d:\Python27\Lib\site-packages\win32lfn\src;d:\Python27\Lib\site-packages\mercurial\
  • Use this cli command, or do the same using some other method
  • Of course, you should adapt paths to your needs
  • Restart your cli after this, to make sure env. variable is now properly set

8. Download win32lfn

  • Check for availible downloads on the project's repository page
  • If there's still nothing, just clone a repository from https://bitbucket.org/remleduff/win32lfn to "d:\Python27\Lib\site-packages\win32lfn\"
  • Now "win32lfn.pyc" should be in "d:\Python27\Lib\site-packages\win32lfn\src\"

9. Do interanal win32lfn tests

cd /D D:\Python27
python d:\Python27\Lib\site-packages\win32lfn\tests\testwin32lfn.py

10. Create a backup of your repository.

  • For me, everything went just fune, but you never know....

11. Add win32lfn to hgrc

[extensions]
win32lfn = d:\Python27\Lib\site-packages\win32lfn\src\win32lfn.py
  • you can find "hgrc" in your ".hg" folder, inside your repository

12. Test it!

like image 44
Igor Avatar answered Sep 19 '22 14:09

Igor