如何解决hg-fast-export错误:"分支名称不符合GIT标准:refs/heads/master"

Ada*_*ada 6 git mercurial

在使用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
Run Code Online (Sandbox Code Playgroud)

错误似乎是:分支名称不符合GIT标准:refs/heads/master

有没有人知道如何解决这个问题?

我的mercurial存储库很干净,工作正常,只有一个头,所有好的和热的准备好导出.

编辑:

我使用TortoiseHG结合hg-git解决了这个问题.对于任何寻找出口mercurial rep的方法的人.git或反之亦然,只需按照此处描述的步骤操作:http://www.ffuts.org/blog/accessing-a-git-repository-with-tortoisehg-on-windows/

Joh*_*zen 9

我刚刚为自己解决了这个问题.

事实证明,Python迫使那里出现了'\r\n'由hg-fast-export输出的每一行的末尾.这意味着分支名称被解释'refs/heads/master\r'为无效.

这个任务的答案......

在向sys.stdout写入换行符时,使Python停止发出回车符

...可以放在hg-fast-export文件的顶部,以便切换到二进制模式.

编辑:
要添加的代码是:

if sys.platform == "win32":
   import os, msvcrt
   msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
Run Code Online (Sandbox Code Playgroud)

只需将它放在hg-fast-export.py的顶部,并确保import sys在顶部有一个.