Join multiple subrepos into one and preserve history in Mercurial

依然范特西╮ 提交于 2019-12-18 04:40:19

问题


Currently I have project consisting of multiple repositories, e.g.:

+---Project (main repo)
    +---Core (subrepo)
    +---Web (subrepo)
    \---Tests (subrepo)

Unfortunately the code between subrepos is quite coupled so it doesn't work nicely with branches.

Is there any way to consolidate the subrepos into one main repository preserving the history?


回答1:


I would start with using hg convert with a filemap that excludes the .hgsub and the subrepos. Next, use hg convert on the subrepos with rename entries in the filemap like: rename . Core

Once you have those new repos, you can use hg pull -f to import the changesets from the converted subrepos into the converted main repo one at a time. You'll also need to merge them into your new main repo (they form separate heads with the null revision as the most recent common ancestor).




回答2:


First guess : Perhaps by using the convert extension with a filemap ?

Another try :

  • Pull all your repos into the same repo, you will have different heads for the "default" branch
  • Then for each head
    • Update to this head
    • Move the files (hg move) into the right directory
  • Merge all the "default" heads together

Edit : added more details, and another try




回答3:


Assuming you don't have to convert repos, why not simply push each repo in the central one?

  1. Make sure each repo root directory have a main directory named after the repo name.
  2. push each repo in the main repo.


来源:https://stackoverflow.com/questions/3882617/join-multiple-subrepos-into-one-and-preserve-history-in-mercurial

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