Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

mercurial

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/

like image 802
Adabada Avatar asked Mar 02 '12 17:03

Adabada


1 Answers

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.

like image 139
John Gietzen Avatar answered Sep 28 '22 00:09

John Gietzen