best practice for maintaining two differents codes in one mercurial repository

I am currently working on two different sub-project. Till now I have had two different mercurial repositories for each. I would like to keep the two sub_projects all in one repository, but then I still would like to be able to work on the two sub_projects simultaneously and separately without having to commit changes from both sub-projects all in one commit. My two sub-projects are totally independent.I would like to be able to commit and see the history of each of the sub-projects independently.

I was wondering what is the best practice in this case. I would like to keep the two sub-projects all in one repo as this will make delivery to the client much easier.

Thank you very much in Advance for your help,


If it's two unrelated code bases, then my recommendation is to NOT merge them into one - it won't make handling any easier.

However if you are set on creating a common code base, then there are different strategies:

a) Just merge them in one repository by pulling one project into the other. This requires that there are no identically-named files in the two repositories. Alternatively use the convert extension onto either to put them into separate paths, then pull the converted repositories into one. You will have to take care manually that you make commits such that you only touch files of one project at a time.

b) Make use of sub-projects. The best choice for separate sub-projects is to use the subrepository extension of mercurial; it's recommended to use a shallow parent repository of which the two sub-projects are just that: sub-repositories. Mind to read the documentation of the subrepositories extension carefully - it's called a 'feature of last resort' for reasons that it does have its rough edges. However you can commit to the single sub-projects separately without touching the other one and create a common state of the projects by making a commit in the parent repo which records the state of the sub-projects.

There are also similar alternative extensions like guest repo and similar - maybe they suit your use case better.

链接地址: http://www.djcxy.com/p/6416.html

上一篇: 在Vim中的光标下从完整路径打开文件

下一篇: 在一个mercurial仓库中维护两个不同代码的最佳实践