Merging unrelated histories will generally result in an incoherent history and is not recommended
To merge two unrelated repositories, preserving history, follow these steps.
hg clone REPO1 work # First pull from both repos... cd work hg pull -f REPO2 hg merge # Then simply merge. hg commit
You can keep pulling changes from both repositories in the future, if you like.
On the other hand, if you're doing this in order to stop using two separate repositories, just hg push REPO1 and you're finished.
Filtering. If you only want to merge certain files or directories from REPO2 into REPO1, you can use the ConvertExtension to create a repository with only the files from REPO2 that you want, then treat that as your REPO2 when following the instructions above.
Renaming. Now suppose you want the files from REPO2 to live in a subdirectory of REPO1 called "lib2". Here's how to do that (without using hg convert):
hg clone REPO1 work # Again, pull from both repos... cd work hg pull -f REPO2 hg update -C tip # Now update to the REPO2 tip... mkdir lib2 # And rename everything... hg rename * lib2 hg commit -m "Move everything into lib2 directory." hg merge # Then simply merge. hg commit
Again, you can continue to pull changes from both repositories if needed. Or not.