Join the DZone community and get the full member experience.Join For Free
simply put, maintained divergence is where you have two branches that have a common origin, and while merges may happen in either direction, there are differences that remain over time.
here, y was branches from x. work is merged over time in either direction (could be enhancements, could be bug fixes). not shown is work that’s deliberately not merged. for a whole commit that is deliberately not mergeable, you could use the source-control tool’s mechanism to not merge it, but mark it as merged. for subversion that is ‘—record-only’, git ‘strategy-ours’, and perforce ‘accept yours’. we’ll call that record-only going forward as svn is the defacto-standard source-control tool. once you’ve done record-only in both directions and no other commits have happened, then the next general merge (without record-only), will say there’s nothing to merge, even though you know the two branches are different. that difference is the maintained divergence aspect, that does not rely on cherry-picks.
having one branch for both (say trunk based development), and have a build that can adapt build both (x and y) from the same source. the adaptability could be represented in #ifdef style source directives (c, c++), or could me more pluggable around abstractions if the languages in question support that. there’s a degree of sophistication to this, that many would argue is not worth the effort. the agile community is nearly always going to say this is better.
apple’s ios and mac
one of the reasons apple were able to conclusively beat at least microsoft’s hand-held operating systems in 2007 was that arm chips had become beefy enough to run their desktop operating system. more or less that is. i hypothesize they made an experimental branch from os x (mac) to prove the point, keeping lots of commonality, dropping plenty (all apps for example), and diverging quickly to what is recognizable today. for the items that are desired in both code-lines, there may be divergence too. either way, record-only merges would set you up, to subsequently be able to merge bug fixes either direction.
both ios and os x have their own release schedules of course. that’s one of the characterizing aspects of this. indeed, it could be that apple will kill os x after growing ios to be all that you need (in their opinion). perhaps they’d do this after allowing mac end-users to install an ios environment (sync’d) for a few releases:
note – i don’t actually know how apple use perforce ‘inside’, or their branching strategy. sadly, there is a bit of a news blackout from devs that join the cupertino company.
bigger games studios
a title may be concurrently developed for xbox 360 and playstation3 by a single studio. there’s a huge amount of c++ source, but also a ton of differences between the two platforms. having a branch for each allows for teams to run against their own release schedule, but benefit from merges where there is commonality.
data instead of ‘source’
let’s take a contrived example: us hotel data, and we’ll change from branches of the same source-control repo, to forks on github (amounts to the same thing):
the first “upstream” branch/fork, is just reduced hotel data. it presumably grows as part of some community effort, in the style of freebase .
then there’s the fork (a team concerned with determining whether the hotels have wifi, and whether that’s free): https://github.com/paul-hammant-fork/us_hotels_with_wifi and their view of the same file .
there’s two differences:
- a correction to the number of stars a hotel has
- the addition of the fact that wifi is free for hilton-honors members with status.
in fact, #1 came after #2 in terms of commits. in this case you’re want to consume the stars correction back to the upstream master, but leave the wifi details divergent as it does not constitute the “reduced” aims of the upstream master. github has “pull requests” where the wifi team could donate changes back to the reduced-hotel-data team, but it does not allow for cherry picking of individual requests, in order to maintain divergence.
here’s the diffs all together -
i previous blogged about semantic merge amongst other things .
the plastic scm team is working on such a thing, not just for their source-control tool, but to have command-line inteop with others . i’ve not used it yet, but look forward to trying it out. it’s relevant to this space i think.
Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.