File Merge: How did we get ourselves into this mess

[article]

of changes.  He could therefore choose to redo Jane's change starting with his current working file.  The problem here is that he might not really know how.  He might have no idea what Jane's approach was.  Jane's office might be 10,000 miles away.  Jane might have written a lousy comment explaining her checkin.

As an alternative, Joe could set aside his working file, start with the latest repository version and redo his own changes.

Bottom line:  If a merge gets this bad, it takes some time and care to resolve it properly.  Luckily, this situation doesn't happen very often.

Verifying the merge
Regardless of which of the above methods is used to complete the merge, it is highly recommended for Joe to verify the correctness of his work.  Obviously he should check that the entire source tree still compiles.  If a test suite is available, he should build and verify that the tests still pass.

After Joe has completed the merge and verified it, he can declare the merge to be "resolved", after which the SCM tool will allow him to checkin the file.  In the case of Vault, this is done by using the Resolve Merge Status command, which explicitly tells the Vault client application that the merge is completed.  At this time, Vault would change the baseline version number from 4 to 5, indicating that as far as anyone knows, Joe made his changes by starting with version 5 of the file, not with version 4.

Since his baseline version now matches the current version of the file, the Vault server will now allow Joe to do his checkin.

Worth the trouble

Best Practice: Give concurrent development a try

Many teams avoid all forms of concurrent development. Their entire team uses "checkout-edit-checkin" with exclusive locks, and they never branch.

For some small teams, this approach works just fine. However, the larger your team, the more frequently a developer becomes "blocked" by having to wait for someone else.

Modern source control systems are designed to make concurrent development easy. Give them a try.

I hope I have not scared you away from concurrent development by explaining the gory details of merging files.  In fact, my goal is quite the opposite.

Remember that easily-resolved merges are the most common case.  Automerge handles a large percentage of situations with no problems at all.  A large percentage of the remaining cases can be easily handled with a visual merge tool.  The difficult situations are rare, and can still be handled easily by a developer who is patient and careful.

Many software teams have discovered that the tradeoff here is worth the trouble.  Concurrent development can bring substantial gains in the productivity of a team.  The extra effort to deal with merge situations is usually a small price to pay.

Looking Ahead
In the next chapter I will be discussing the concept of a repository in a lot more detail.


Eric Sink is a software developer at SourceGearwho make source control (aka "version control", "SCM") tools for Windows developers. He founded the AbiWord project and was responsible for much of the original design and implementation. Prior to SourceGear, he was the Project Lead for the browser team at Spyglass (now OpenTV) who built the original versions of the browser you now know as "Internet Explorer". Eric received his B.S. in Computer Science from the University of Illinois at Urbana-Champaign. The title on Eric's business card says "Software Craftsman". You can Eric at

About the author

TechWell Contributor's picture TechWell Contributor

The opinions and positions expressed within these guest posts are those of the author alone and do not represent those of the TechWell Community Sites. Guest authors represent that they have the right to distribute this content and that such content is not violating the legal rights of others. If you would like to contribute content to a TechWell Community Site, email editors@techwell.com.

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!

Upcoming Events

Nov 09
Nov 09
Apr 13
May 03