Lieberta
Lieberta

Reputation: 147

Merging two different directory trees - Mercurial

I am here to ask a sort of theoretical question since I am working on a merging proof of concept for two Mercurial repositories. Currently, I have two repositories with entirely different tree structure. Let's call them Repo A and Repo B.

The directories looks as following:

Repo A                                Repo B 
|                                     |
Dir A -- Dir A1 -- File A             Dir A --- Dir A1 -- Dir A2 -- File A2
|                                           |   File A    File A1   
Dir B -- Dir B1 -- File B1                  |
         File B                             |-- Dir B -- File B

So, in Repo A , the dir B is present in the same level as dir A but in Repo B, dir B exist inside of dir A. Both of them are active repositories so they have their own code changes histories but Repo B has the latest changes for dir B.

What I would like to achieve is to merge Repo B onto Repo A tree structure and maintain the change set history and tags of both repo A and repo B for dir A and dir B without losing anything.

I've read an article http://hgtip.com/tips/advanced/2009-11-17-combining-repositories/ but I'm not sure if its applicable in what I am trying to do. If there is a similar question before mine, please help point the link out. Or any useful articles will help too.

Otherwise, guidance from all of you will be great. XDD

Thanks.

Upvotes: 1

Views: 237

Answers (1)

planetmaker
planetmaker

Reputation: 6044

Indeed, you basically linked one version of the answer already yourself - that's exactly what you want to do:

  • prepare one repo (or both) such that the internal directory structure matches eachother, so that no naming conflicts occur for stuff which needs to stay separate and those things which are the same are named identically
  • pull one repository into the other. You will be warned that you are pulling from an unrelated repository. That's fine, that's what you want to do. You will end up with a repository with two independent branches.
  • merge the two branches and resolve the conflicts in the manner you need

You see one such thing in this one example repo where we merged two closely related tools into one code base.

Upvotes: 1

Related Questions