ItGo.me Focus on IT Recommend

Home > mercurial - How to solve hg-fast-export error: "Branch name doesn't conform to GIT standards: refs/heads/master"

mercurial - How to solve hg-fast-export error: "Branch name doesn't conform to GIT standards: refs/heads/master"

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
入口地址https://www.aliyun.com/minisite/goods

After solving countless problems with the hg-fast-export tool on Windows (from finicky python version needed to cleaning up mercurial repository to satisfy the tool) I have stumbled upon a n error that I cannot solve:

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

The error seems to be: Branch name doesn't conform to GIT standards: refs/heads/master

Does anyone have a clue on how to solve this issue?

My mercurial repository is clean and working properly, with only one head, all nice and hot ready to be exported.

EDIT:

I solved the problem by using TortoiseHG combined with hg-git. For anyone looking for a way to export a mercurial rep. to git or vice-versa, just follow the steps described here: http://www.ffuts.org/blog/accessing-a-git-repository-with-tortoisehg-on-windows/

git mercurial
edited Apr 15 '12 at 22:47 asked Mar 2 '12 at 17:11 Adabada 128 12      what is the output of hg branches ? –  krtek Mar 5 '12 at 7:26

 | 

1 Answers
1

---Accepted---Accepted---Accepted---

I just solved this problem for myself.

It turns out that Python was forcing there to be a '\r\n' at the end of every line that was output by hg-fast-export. This meant that the branch names were being interpreted like 'refs/heads/master\r', which is invalid.

The answer to this questsion...

Make Python stop emitting a carriage return when writing newlines to sys.stdout

...can be placed at the top of the hg-fast-export file, in order to switch to a binary mode.

EDIT:
The code to add is:

if sys.platform == "win32":
   import os, msvcrt
   msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)

Just place it at the top of hg-fast-export.py and make sure you have an import sys at the top.


edited Sep 5 '12 at 23:02 answered Apr 4 '12 at 23:02 John Gietzen 32.9k 22 109 164      I tried that and it did not helped. –  Adabada Apr 15 '12 at 22:44      Although I never touched the hg-export file. I'm marking this as an answer but I strongly recommend anyone wanting to mix mercurial and git to go with the TortoiseHG and hg-git route. It's easier, faster and even has a nice UI you can use. –  Adabada Apr 15 '12 at 22:51      It worked for me. msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) at the top hg-fast-export.py worked like a charm. –  Tim Swast May 2 '12 at 18:35      Worked for me too. Just only do what Tim Swast said. –  Aurélien Ribon Sep 5 '12 at 17:18      Note for Bazaar (bzr) users: The same error may be raised when doing a bzr fast-export and git fast-import on Windows, using PowerShell. To avoid the problem, simply use the cmd.exe shell instead of PowerShell (which seems to mess with line endings). –  bdoering Sep 16 '15 at 13:05

 | 

Recommend:powershell - branch name does not conform to git standards: refs/heads/master

tailed error report is as follows: D:\demo_history7 [master +4 ~0 -0 !]> .\testscript.ps1 -CSVFileName Report_Recent.csv |git fast-import fatal: Branch name doesn't conform to GIT standards: refs/heads/master fast-import: dumping crash repo

------splitte line----------------------------