I'm starting with a Mercurial repository which has multiple subrepositories that I'm trying to merge into it, as if they had always been a part of the main repository. They should have never been subrepositories in the first place.
I put together a process to convert the old history into a single repository:
- Take a sub-repo and hg convert it using --filemap to move everything into a subdirectory with the name of the directory it should end up in, as described here: Join multiple subrepos into one and preserve history in Mercurial
- Grab a list of revision from each of the repositories using Clay Lenhart's answer here: Is it possible to manually change/reorder the revision numbers (provided topology remains the same)?
- Sort all the revisions by date, from all the repositories to be merged.
- Pull each revision, one by one, into a single new repository.
- Do an hg convert on the resulting repository using a python script, as described here: https://www.mercurial-scm.org/wiki/ConvertExtension#Customization, to strip out references to the subrepository in .hgsub and .hgsubstate files
- Manually merge the branches.
The problem I'm left with is that the history is unusable, i.e. I can't go back and update to a specific version, because each branch only has its own data. So let's say my main repo is A and my subrepos are B and C: if I update to history of branch A, it doesn't have the files from branch B or branch C, and if I update to history of branch B, it doesn't have files from branch A or branch C.
What I want is some way to merge the whole history together, so it is mostly a single branch, and the files from all the branches appear in each commit. Is there a way to convert it so all the history of the branches are merged, and not just a single merge at the very end?