Mark Ivey
Mark Ivey

Reputation: 176

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.

Upvotes: 3

Views: 510

Answers (4)

VonC
VonC

Reputation: 1324268

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.

Upvotes: 3

Tim Delaney
Tim Delaney

Reputation: 5605

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.

Upvotes: 0

Avi
Avi

Reputation: 20142

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.

Upvotes: 0

nonopolarity
nonopolarity

Reputation: 151006

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.

Upvotes: 0

Related Questions