Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding changes from one Mercurial repository to another

When changing the VCS for my project FakeItEasy from SVN to Mercurial on Google Code I was a bit too eager (I'm funny like that). What I did was just checking the latest version out of SVN and then commiting that checkout as the first revision of the new Mercurial repo. This obviously has the effect that all history is lost.

Later when getting a bit better acustomed to Mercurial I realized that there is such a thing as a "convert extension" that allows you to convert a SVN repo into a Mercurial repo. Now what I want to do is to convert the old SVN repo and then have all change sets from the currently existing Mercurial repo imported into this converted repo except the very first commit to Mercurial.

I've converted the SVN repo to a local Mercurial repo but now is when I'm stuck. I thought I'd be able to use the convert extension to bring the current Mercurial repository into the converted one and having a splice map remove the first commit but I can not seem to get this to work.

I've also tried to just use convert without splice map to get all change sets from the current Mercurial repo into the converted one and the rebase the second version in the current to the last commit from the old SVN repository but I can't get that to work either.

To make this clearer lets say I have these two repositories:

A: revA1-revA2
B: revB1-revB2-revB3 (Where revB1 is actually a copy of revA2)

Now I want to combine these two into the new repository containing this:

C: revA1-revA2-revB2-revB3
like image 934
Patrik Hägne Avatar asked Apr 21 '10 16:04

Patrik Hägne


1 Answers

So long as you're changing the hashes on the new revisions (you are), you might as well just use export and import (or the transplant command that is a wrapper around the two).

You already did your convert, which is great, now go into repo B and do:

hg export -o 'changeset-%R.patch' 1:tip

that will create a changeset-##.patch for each changeset in repo B, except the first (numbered zero).

Now go to repo C and import them:

hg import $(ls *.patch | sort -V)

That should all apply cleanly if indeed the revA2 and revB1 were identical.

like image 117
Ry4an Brase Avatar answered Sep 22 '22 02:09

Ry4an Brase