Skip to content

Instantly share code, notes, and snippets.

@Swyter
Last active June 4, 2017 23:08
Show Gist options
  • Save Swyter/8d2e161958db9a4494c284d5a4d676cb to your computer and use it in GitHub Desktop.
Save Swyter/8d2e161958db9a4494c284d5a4d676cb to your computer and use it in GitHub Desktop.
Fix the «Error: repository has at least one unnamed head» issue with the Hg to Git converter by removing the previous merge with two parents and using a recreated repository by joining two different trees with no common history linearly.
Lifesaver answer from a knowledgeable Hg master:
https://stackoverflow.com/questions/19215571/add-a-parent-to-the-original-changeset-in-mercurial
We have:
A---B---C---D---E---F
X---Y---Z
We want:
X---Y---Z---A---B---C---D---E---F
^ ^
hg log --template '{node} ' -r d1b5b00ccc4dd6f265fd42fdd3e9cf4d54d43020 -r 41d6405688b56928ca8ed6a65138aab9d266d325 > splicemap
(Contents of splicemap: d1b5b00ccc4dd6f265fd42fdd3e9cf4d54d43020 41d6405688b56928ca8ed6a65138aab9d266d325)
(Where 41d6405688b5 is Z and d1b5b00ccc4d is A)
hg convert --splicemap splicemap . spliced
(We get a recreated Hg repo, now linear, the only parent -1 (000000000000) is revision 0)
mkdir wconquest-msys-git && cd ../swconquest-msys-git && git init .
../fast-export/hg-fast-export.sh -r ../swconquest-msys/spliced/ -A ../authors-msys
That's it. No more errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment