Mercurial merge repository as branch

假如想象 提交于 2019-12-05 13:54:46

I originally thought I'd need some way to pull into just the branch, but after chewing on it some more, I concluded the best way to do this is roughly as follows:

  1. Create the desired new branch structure (i.e. create the 4.6 and 5.0 branches).
  2. Remove the old default branch into the 4.6 branch in the base repository.
  3. Pull the project-5.x repository into the project-4.x repository.
  4. Merge the default (or in the case of this repository, experimental) baseline, which is pulled in during the merge, into the 5.0 branch, closing out the experimental branch along the way.
  5. Restrict write access to the old repository's central push/pull location; we still have it for historical reasons, but people can't accidentally push to it.

Preparation (steps 1–2)

$ cd <project-4.x directory>
$ hg branch 4.6
$ hg ci -m "New 4.0 baseline"
$ hg branch 5.0
$ hg ci -m "New 5.0 baseline"
$ hg up default
$ hg ci --close-branch -m "Close default branch going forward.
$ hg up 4.6
$ hg merge default
$ hg ci -m "branch merge default -> 4.6"

At this point, the repository is set up: it has the new baseline branches and has removed the old default branch we wanted to get rid of.

After this, I made the changes to get the repository structure looking more the way it needed to for the 5.0 branch in the project-4.x repository (since massive restructuring is part of the version change effort).

Repository merge (steps 3–4)

The next step was actually merging the repositories together and pushing the content from the old repository into the desired branch.

$ hg pull -f <path to project-5.x repository>   # still in project-4.x repository
$ hg merge -m "Merge in project-5.x repository"
$ hg up experimental   # experimental is the name of the "default" branch
$ hg ci --close-branch -m "Close experimental branch"
$ hg up 5.0
$ hg merge experimental
$ hg ci -m "Merge old experimental into new 5.0 baseline"

This proceeded perfectly, with no merge conflicts whatsoever (except that I needed to resolve some small differences in my .hgignore file).

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