开发者

Using mercurial on divergent branches

What is a good workflow for using mercurial with two long-running branches that are slightly divergent (i.e. I never intend to entirely merge them back together)?

开发者_开发技巧

In my case, this is CMS software that has been customized differently for two different web sites. I started with projectA, and once that was working cloned it to projectB and make further tweaks to both A and B to customize them. Now I want to develop some features that show up in both A and B, without merging the site-specific customizations. How?

hg push will push everything, so that won't work

Transplant appears to give me different changeset hashes, which worries me

I feel like maybe the repositories should be set up differently, but I'm not sure how.


As Thilo comments, the common part would be best developed (and published in A and B) as a third repo declared as a SubRepo.

That way, you respect the first two repos which are independent (one evolution on A doesn't always mean an evolution on B), and you can develop the common part in subrepo C.


A solution for Mercurial might be if you can put the different areas in files that can be in .hgignore, but then they won't be versioned, so that may not be so good.

Another way is to just use 1 repo, and set a global flag, and use template A or B depending on the flag, and / or include different code source file depending on the flag. If the difference is small, then can use if-then-else inside the same file.


You can use hg push to push the changes back together, but you don't necessarily have to merge all the changesets into the trunk. Just take the ones you want.


As stated above, a subrepo is probably the best option. Another alternative would be to have a third branch with the common work, and merge from that branch to projectA and projectB (but never back to the common branch).

This alternative is more likely to have accidents (merging the wrong way) but you might find that it is easier to set up and get working quickly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜