How to combine two projects in Mercurial?

I have two separate mercurial repositories. At this point it makes sense that they "become one" because I want to work on the two projects simultaneously.

I'd really like the two projects to each be a subdirectory in the new repository.

  1. How do I merge the two projects?
  2. Is this a good idea, or should I keep them separate?

It seems I ought to be able to push from one repository to the other... Maybe this is really straight forward?


I was able to combine my two repositories in this way:

  1. Use hg clone first_repository to clone one of the repositories.
  2. Use hg pull -f other_repository to pull the code in from the other repository.

The -f (force) flag on the pull is the key -- it says to ignore the fact that the two repositories are not from the same source.

Here are the docs for this feature.


hg started to have subrepo since 1.3 (2009-07-01). The early versions were incomplete and shaky but now it's pretty usable.


If you aren't using the same code across the projects, keep them separate. You can set your personal repository of each of those projects to be just a directory apart. Why mix all the branches, merges, and commit comments when you don't have to.

About your edit: Pushing from One repository to Another. You can always use the transplant command. Although, all this is really side stepping your desire to combine the two, so you might feel uncomfortable using my suggestions. Then you can use the forest extension, or something.

hg transplant -s REPOSITORY lower_rev:high_rev