views:

675

answers:

4

I am wanting to toy around with Mercurial a bit, so I am trying to convert one of my existing repositories over. I run the following command on my Mac:

hg convert myrepos myrepos-hg

The command successfully imports all of my commits, but it doesn't bring along the 8 or so tags that were marked in the Git repository (nor are any of the branches for that matter). Is there a special parameter I need to set to have my tags imported into Mercurial as well?

+3  A: 

This is a somewhat known issue. You can try patching the following file /usr/lib/python2.6/site-packages/hgext/convert/hg.py (or wherever it's located) by changing this:

extra = {'branch': self.tagsbranch}

to:

extra = {'branch': 'default'}

and then converting it again.

EDIT: On a deeper look at the state of things it seems that it may be difficult--it not impossible--to do what you want. Even more so to do it correctly.

Since you only have 8 tags consider saving yourself the hassle by crafting the .hgtags file by hand. You can figure out what's up with 'hg convert' later (I'll keep my eyes pealed as well).

Luck.

Fake Code Monkey Rashid
I modified the file as accordingly (it was located in /Library/Python/2.5/site-packages/...), but unfortunately it's still not converting the tags and creating the .hgtags file.
Justin Williams
A: 

One suggestion I've seen in the past is to use svn as an intermediary step. Both git and hg have excellent bidirectional svn conversion.

Ry4an
+1  A: 

Check out the hg-git plugin.

Joshua
+5  A: 

Are your tags lightweight git tags or full on annotated tags? hg convert only converts annotated tags, but git by default creates lightweight ones. I had this issue when converting one of my repositories recently. You can check what they are as follows:

git ls-remote --tags .

Running hg convert will only convert the tags that end in ^{}, the annotated ones. You have 2 choices:

  • patch the git.py hgext convert extension file to convert all types
  • change your git tags to annotated tags prior to conversion

With a small shell script and the --force option to git-tag you can annotate all of your tags.

rq
That was the problem. Thanks for the tip!
Justin Williams