Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert my Git repository to Mercurial and bring along its tags

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?

like image 604
Justin Williams Avatar asked Jul 18 '09 03:07

Justin Williams


2 Answers

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.

like image 86
richq Avatar answered Sep 23 '22 08:09

richq


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.

like image 38
Fake Code Monkey Rashid Avatar answered Sep 23 '22 08:09

Fake Code Monkey Rashid