如何在 Mercurial 中组合两个项目?

我有两个独立的汞存储库。在这一点上,它们“合二为一”是有意义的,因为我想同时处理这两个项目。

我希望这两个项目都是新存储库中的一个子目录。

  1. 如何合并两个项目?
  2. 这是个好主意吗,还是我 把他们分开?

看起来我应该可以从一个仓库推到另一个仓库... 也许这真的很直接?

14851 次浏览

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

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.