November 18, 2011

Why You Need the Best Merge Engine » Poor Base Selection


One of the highlights of the 2011.1 release, is the next generation merge (integration) engine. Perforce's merge engine can now handle just about any sticky problem you can think of, as Sam Stafford wrote about earlier.

But it would be a mistake to think that you only need the best merge engine if you're doing very tricky development and release management. Merges gone wrong can cause all sorts of grief, and that grief boils down to lost productivity.

  • Introducing old changes or unnecessary conflicts requires manually intensive, error-prone correction.
  • If you don't trust automated merge results, you'll spend a lot of time manually verifying merges.
  • If bad automatic merges cause subtle problems that aren't detected until functional testing, you'll be less likely to take advantage of build and release automation.

Even in simple cases, having a less-then-stellar merge engine will cause trouble. Take a look at this diagram, which shows the problems that Subversion runs into due to poor base selection:

Anders Catch-22 SVN
Subversion merge: Unnecessary merge conflicts anyone?

Choosing a better merge base gives us a clean merge in this case. Try this scenario in Perforce and you'll get a clean automatic merge. (A hint for the curious: run p4 resolve -oto see which revision Perforce uses as a merge base.)

And here's a case where not handling prior merge history will re-introduce some previously ignored content. Tracking down these problems can be difficult, particularly if the incorrect diffs cause subtle corruption.

Merge Ignore
Subversion merge: Reintroducing old changes in a merge

Again, in this scenario Perforce correctly handles the prior merge history and does not try to re-introduce old content.

Note that these cases really aren't very complex; you can run into interesting merge situations a lot sooner than you might think.

We've got a more detailed write-up of some of these test cases if you're interested; needless to say, Perforce handles all of these without trouble.

But the bottom line is that, even in simple cases, having the world's best merge engine will save you time and effort. Grab the 2011.1 Perforce release and see for yourself.