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?
2 に答える
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"
Maybe. Try this approach:
- Clone repo #1
- Create a set of patches using
hg export
from repo #2 - 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.