How to adjust history after merge of two unrelated Mercurial repositories?

丶灬走出姿态 提交于 2019-12-04 07:48:30

Merging unrelated histories doesn't work well because each changeset is a snapshot of the project at some state. If you simply pull -f or graft with convert, you'll get a repository with clearly unrelated history grafted together. You won't get a nice tidy history that shows the grafted-on history being added to the main project a commit at a time like you'd want. Instead you'll get a bunch of the commits with files only from project A, and a bunch with only files from project B. In short, this is because "things didn't actually happen that way". Stitching together history graphs won't fix up the contents of those changesets.

So the only available answer is to actually replay the history of project B inside of project A a commit at a time, and in the right part of A's directory namespace. This can either be done "by hand" with hg export + import or with some combination of hg convert --filemap and transplant or rebase.

I've adjusted the wiki page you mentioned to deprecate that 'advice'. Generally speaking, I don't recommend trying to do this sort of thing at all, again because "it didn't actually happen that way". It's better to just pull in the whole history of project B in one commit and have a pointer back to its true history in your commit message.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!