问题
So, basically about every time I try to do an update to my changed files, I get this awful error. I then have to manually select only some of the files, define a commit message, then come back and select some more files, put other commit text, etc, etc until I have covered all the changed files.
Is there anything simpler, dammit?
I am using Tortoise HG in Visual Studio 2010 ( http://www.newsupaplex.pp.ru/index_eng.html ), if it makes any difference.
回答1:
HgSccPackage uses mercurial command line client hg.exe. There is a limitation on maximum command line length ~2000 characters in the .Net framework API used to run an external process (hg.exe).
And since the commit must be atomic the HgSccPackage fail to complete operation with that error.
You have three options:
- You have an option to check all changed files in commit window. Then HgSccPackage will call mercurial client to commit all files (without passing each and every one in command line arguments).
- If it is possible, you can split commit to smaller logical parts with fewer files.
- If it is possible, revert some files and commit all other at once
It would be much easier if the mercurial client had an option to pass a file list in a file (for example list.txt with file names in each line). But there is no such option.
By the way, the HgSccPackage does not pass a full path for files. Instead it pass the file path relative to the repository root. So, it rather strange, that you hit the command line limit.
How much files you are commiting ? Why can't you commit all files ?
回答2:
Mercurial SCC Package checks whether the resulting command line is not greater than 1,700 characters.
I've digged package's source code a bit and apparently when invoking Mercurial's commands it ends up with using Process.Start()
method on hg.exe
with UseShellExecute = false
option specified.
Process.Start method's documentation mentions that the sum of the length of the arguments and the length of the full path to the process shouldn't exceed 2080 but digging the .NET Framework itself I was unable to find any enforcement of that limitation. WinAPI CreateProcess function (with which Process.Start
effectively ends up calling to) have more generous limitation of 32,768 characters.
So it might be bug with VS addin.
As for me when I had a similar problem because my projects was too deep inside C:\Documents and Settings\Regent\My Documents\Visual Studio 2010\Projects\
I just created a NTFS symbolic link and used C:\Projects\
afterwards.
来源:https://stackoverflow.com/questions/4512321/resulting-command-line-for-hg-exe-too-long-error-in-mercurial