kovica
kovica

Reputation: 2583

Merge different repositories into one

I have two different Mercurial repositories, each with its own history. Is there a way to merge the two into one repository that would also have complete history of both?

Upvotes: 2

Views: 418

Answers (2)

Steve Kaye
Steve Kaye

Reputation: 6262

You can pull one into the other with the -f flag:

> cd path\to\repo1
> hg pull -f path\to\repo2
> hg merge

.... deal with merge conflicts ....

> hg commit -m "Merge with repo2"

Upvotes: 3

Aaron Digulla
Aaron Digulla

Reputation: 328556

Maybe. Try this approach:

  1. Clone repo #1
  2. Create a set of patches using hg export from repo #2
  3. Import the patches into the clone using hg import

This will fail when the two repos have common files. The solution here will be to apply the failing patches using hg patch.

Background: Mercurial creates a checksum for each changeset. This strong cryptographic checksum contains the modification date, the user name, checksums of the parent changeset(s) and the patch.

This means if you try to copy a changeset from one repo to another, this will fail simply because the parent changeset(s) can't be found. It's not easy to add the parent changeset because of the checksums.

Upvotes: 1

Related Questions