tags:

views:

1697

answers:

4

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?

+1  A: 

Not sure. But will the Forest Extension work for you?

cnu
+2  A: 

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
nlucaroni
+18  A: 

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 ingore the fact that the two repositories aren't from the same source

jm
Does this preserve the commits' hash keys from the second repo too? (I'd guess not, but it might be ok until you do a merge.)
Marcus Lindblom
@marcus-lindblom I don't know.
jm
This works, but you'll need to also run `hg merge` to finally get everything working
Factor Mystic
**@Marcus Lindblom:** pulling a changeset will never, *ever* change its hash. If you look at `hg glog` after doing this you'll see you have two unrelated lines of changesets. The first changeset in each line has no parent, but that's not a problem for Mercurial. Once you pull you'll want to make one new changeset for each line where you `hg mv` everything into the appropriate subfolder, then you merge the lines and you're all set.
Steve Losh
Im about to do the same, I was wondering (since its been some time now since you did this) if you ever encountered any problems using the mega-merged clone?
mizipzor
I don't remember running into any further problems. But I don't remember which repository I did this on, either :)
jm
+2  A: 

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

Geoffrey Zheng
That is a cool feature.
jm