在使用Windows上的hg-fast-export工具解决了无数问题后(从清理mercurial存储库以满足工具需要的finicky python版本)我偶然发现了一个我无法解决的错误:
master: Exporting full revision 1/98 with 142/0/0 added/changed/removed files
fatal: Branch name doesn't conform to GIT standards: refs/heads/master
fast-import: dumping crash report to .git/fast_import_crash_5956
Traceback (most recent call last):
File "../fast-export/hg-fast-export.py", line 388, in <module>
options.statusfile,authors=a,sob=options.sob,force=options.force))
File "../fast-export/hg-fast-export.py", line 322, in hg2git
c=export_commit(ui,repo,rev,old_marks,max,c,authors,sob,brmap)
File "../fast-export/hg-fast-export.py", line 214, in export_commit
export_file_contents(ctx,man,added)
File "../fast-export/hg-fast-export.py", line 126, in export_file_contents
wr(d)
File "../fast-export/hg-fast-export.py", line 28, in wr
print msg
File "c:\Python26\lib\site-packages\mercurial\windows.py", line 70, in write
raise IOError(errno.EPIPE, 'Broken pipe')
IOError: [Errno 32] Broken pipe
错误似乎是:分支名称不符合GIT标准:refs / heads / master
有没有人知道如何解决这个问题?
我的mercurial存储库干净且工作正常,只有一个头,所有好的和热的准备好导出。
修改
我使用TortoiseHG结合hg-git解决了这个问题。对于任何寻找出口mercurial rep的方法的人。要git,反之亦然,只需按照此处描述的步骤操作:http://www.ffuts.org/blog/accessing-a-git-repository-with-tortoisehg-on-windows/
答案 0 :(得分:9)
我刚刚为自己解决了这个问题。
事实证明,Python迫使hg-fast-export输出的每一行末尾都有一个'\r\n'
。这意味着分支名称被解释为'refs/heads/master\r'
,这是无效的。
这个任务的答案......
Make Python stop emitting a carriage return when writing newlines to sys.stdout
...可以放在hg-fast-export文件的顶部,以便切换到二进制模式。
修改强>
要添加的代码是:
if sys.platform == "win32":
import os, msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
只需将其放在hg-fast-export.py的顶部,并确保顶部有import sys
。