【问题标题】:How to solve hg-fast-export error: "Branch name doesn't conform to GIT standards: refs/heads/master"如何解决 hg-fast-export 错误:“分支名称不符合 GIT 标准:refs/heads/master”
【发布时间】:2012-03-21 04:50:23
【问题描述】:

在使用 Windows 上的 hg-fast-export 工具解决了无数问题后(从需要清理 mercurial 存储库以满足该工具的挑剔 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 解决了这个问题。对于任何正在寻找导出善变代表的方法的人。要 git 或反之亦然,只需按照此处描述的步骤操作:http://www.ffuts.org/blog/accessing-a-git-repository-with-tortoisehg-on-windows/

【问题讨论】:

  • hg branches 的输出是什么?

标签: git mercurial


【解决方案1】:

我刚刚自己解决了这个问题。

事实证明,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

【讨论】:

  • 虽然我从未接触过 hg-export 文件。我将此标记为答案,但我强烈建议任何想要将 mercurial 和 git 混合使用 TortoiseHG 和 hg-git 路线的人。它更简单、更快捷,甚至还有一个不错的用户界面可供您使用。
  • 它对我有用。 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) 在顶部 hg-fast-export.py 就像一个魅力。
  • 也为我工作。只做蒂姆·斯瓦斯特说的。
  • Bazaar (bzr) 用户注意事项:在 Windows 上使用 PowerShell 执行 bzr fast-exportgit fast-import 时可能会引发相同的错误。为避免此问题,只需使用cmd.exe shell 而不是 PowerShell(这似乎与行尾混淆)。
猜你喜欢
  • 2016-06-24
  • 1970-01-01
  • 1970-01-01
  • 2022-10-24
  • 1970-01-01
  • 2017-05-10
  • 1970-01-01
  • 2019-10-26
  • 1970-01-01
相关资源
最近更新 更多