This is by designed. Imported Git branches are only labeled in Mercurial, and hg heads
should give you the correct number of imported "branches".
As mentioned in this thread:
Consider a tree that looks like this:
o-o-o-o-o-o-b <- branch foo
/
-o-o-a
\
o-o-c <- branch bar
What branch are "a" and its ancestors on?
We haven't the slightest clue. In fact, the only changesets we have any certainty about are b nd c because branch names aren't part of history.
So:
Turns out it's actually impossible to do this right, because git doesn't store enough information.
Consider a repo with two branches in git, each with a number of commits.
Because git doesn't record which branch each commit originated on, there isn't enough information in the tree to label each changeset.
A git user can swap the names of the two branches and nothing is recorded to say it was ever different. If two branches have a common ancestor (and they almost certainly will),
what branch is that ancestor on? We don't know.
The best we can do in the general case is to label each branch head as being on that branch. Then if you do an incremental conversion, we'll probably do the right thing. But git's concept of branches aren't a perfect match to hg's so this conversion won't be perfect either.
You can test it with a small Git repo (Git 1.6.5.1, Hg1.3.1):
PS C:\Prog\Git\tests> cd .\hgimport
PS C:\Prog\Git\tests\hgimport> git init gitRepoToImport
PS C:\Prog\Git\tests\hgimport> cd .\gitRepoToImport
PS [...]\gitRepoToImport> echo firstContentToBr1 > br1.txt
PS [...]\gitRepoToImport> echo firstContentToBr2 > br2.txt
PS [...]\gitRepoToImport> echo firstContentToBr3 > br3.txt
PS [...]\gitRepoToImport> git add -A
PS [...]\gitRepoToImport> git commit -a -m "first content, to be evolved in three different branches"
Make a bunch of modifications in three separate branches:
PS [...]\gitRepoToImport> git checkout -b br1
PS [...]\gitRepoToImport> echo firstEvolutionInBr1 >> .\br1.txt
PS [...]\gitRepoToImport> git commit -a -m "first evolution in branch 1"
PS [...]\gitRepoToImport> echo secondEvolutionInBr1 >> .\br1.txt
PS [...]\gitRepoToImport> git commit -a -m "second evolution in branch 1"
PS [...]\gitRepoToImport> git checkout master
PS [...]\gitRepoToImport> git checkout -b br2
PS [...]\gitRepoToImport> echo firstEvolutionInBr1 >> .\br2.txt
PS [...]\gitRepoToImport> git commit -a -m "first evolution in branch 2"
PS [...]\gitRepoToImport> git checkout master
PS [...]\gitRepoToImport> git checkout -b br3
PS [...]\gitRepoToImport> echo firstEvolutionInBr3 >> .\br3.txt
PS [...]\gitRepoToImport> git commit -a -m "first evolution in branch 3"
PS [...]\gitRepoToImport> echo secondEvolutionInBr3 >> .\br3.txt
PS [...]\gitRepoToImport> git commit -a -m "second evolution in branch 3"
PS [...]\gitRepoToImport> echo thirdEvolutionInBr3 >> .\br3.txt
PS [...]\gitRepoToImport> git commit -a -m "third evolution in branch 3"
PS [...]\gitRepoToImport> git checkout br2
PS [...]\gitRepoToImport> echo secondEvolutionInBr2 >> .\br2.txt
PS [...]\gitRepoToImport> git commit -a -m "second evolution in branch 2"
PS [...]\gitRepoToImport> git checkout br1
PS [...]\gitRepoToImport> echo thirdEvolutionInBr3 >> .\br1.txt
PS [...]\gitRepoToImport> git commit -a -m "third evolution in branch 1"
PS [...]\gitRepoToImport> git checkout br2
PS [...]\gitRepoToImport> echo thirdEvolutionInBr3 >> .\br2.txt
PS [...]\gitRepoToImport> git commit -a -m "third evolution in branch 2"
Then clone that Git repo (just in case, to male other tests)
PS [...]\gitRepoToImport> cd ..
PS C:\Prog\Git\tests\hgimport> git clone .\gitRepoToImport gitRepoToImport1
Configure your ~/.hgrc
with a format UTF-8
without BOM (took me a while to get it right!)
[extensions]
hgext.convert =
Then make the conversion
PS C:\Prog\Git\tests\hgimport> hg convert .\gitRepoToImport1 hgRepo
PS C:\Prog\Git\tests\hgimport> cd .\hgRepo
PS C:\Prog\Git\tests\hgimport\hgRepo> hg heads
You will get the three expected "branches"
changeset: 9:ad0884395ada
tag: tip
user: VonC
date: Mon Nov 16 21:45:35 2009 +0100
summary: third evolution in branch 2
changeset: 6:854bc6537c7c
user: VonC
date: Mon Nov 16 21:45:19 2009 +0100
summary: third evolution in branch 1
changeset: 3:9194cf25d3ca
user: VonC
date: Mon Nov 16 21:44:09 2009 +0100
summary: third evolution in branch 3