Codeline Merging and Locking: Continuous Updates and Two-Phased Commits

differencing/comparison, and even 'rollback' his workspace if necessary).

Ready-to-commit: Finally, Fred will be ready to perform a Task-Level Commit to checkin his changes to the codeline (which hopefully no one else has attempted while Fred was going through all of this commit-preparation work). The Task-Level Commit ensures that the set of changes ( change-set) for a change-task are checked-in to the codeline as a single atomic transaction: either the checkin succeeds for all of the files in the change-set, or it succeeds for none of them.

Two-Phased Codeline-Commit

It is no coincidence that the above appears similar to the 'two-phased commit' protocol used by databases to ensure the ACID properties for a database transaction (ACID is an acronym for Atomicity-Consistency-Isolation-Durability). Many version control tools employ 'transaction-based CM' mechanisms [5]. The standard Two-Phase Commit protocol consists of:

Phase 1 - Preparation : For Fred, this is what he was doing in order to ensure his workspace was up-to-date and working properly with the latest state of the codeline. He started with a Workspace-Update (which perhaps really should have been preceded by a Private Checkpoint ) to synchronize with the codeline, then followed-up with a Private System Build to make sure it still worked properly.

Phase 2 - Commit : This is the actual committing (atomic checkin) of all modified files to the codeline. The Task-Level Commit operation commences when the first file in the change-set is about to be checked-in to the codeline; it successfully completes after the last file in the change-set has been checked-in to the codeline.

As we noted above however, it is still possible that another developer may commit their changes during the time that Fred was performing his commit-preparation activities. A Task-Level Commit ensures that all files modified for a change-task are committed together all at once as a single operation - it does not prevent a change from being committed while others are committing or preparing to commit their changes.

Concurrent Codeline Commit Contention

This is what happens when more than one developer wishes to merge their changes to the codeline during the same period of time. The "window of opportunity" doesn't just refer to the time when the actual codeline "commit" operation starts and ends. It refers to the period of time in between when a developer first knows their changes are good/stable enough to commit to the codeline (and is about to begin commit-preparation activities), up until the time they finish merging those changes to the codeline.

Suppose our 'Fantastic Fred' has finished making all his changes and has successfully committed them to the codeline. We neglected to mention Fred's other teammates: Barney and Betty. Both Barney and Betty have also been busy with their own change-tasks. When Fred finished committing his changes, they both tried to be next to commit their changes. Both tried to execute their commit-preparation activities as quickly as possible. Betty beat Barney and committed her changes first!

So now poor Barney needs to keep re-checking and re-updating his workspace because the codeline he is trying to commit to is a moving target. Barney hates trying to hit a moving target and wants to devise some tactics to prevent this situation. He has two ideas about how to do this:

  1. Perhaps some rule or 'locking' mechanism can help ensure that both phases of the codeline-commit process are treated as part of a single atomic transaction.
  2. Or maybe Barney just needs to find a way to decrease the amount of time consumed by his commit-preparation activities.

Barney feels inclined to investigate both of these alternatives. He decides

About the author

Brad Appleton's picture
Brad Appleton

Brad Appleton is a software CM/ALM solution architect and lean/agile development champion at a large telecommunications company. Currently he helps projects and teams adopt and apply lean/agile development and CM/ALM practices and tools. He is coauthor of the bookSoftware Configuration Management Patterns, a columnist in The CM Journal and The Agile Journal at CMCrossroads.com, and a former section editor for The C++ Report. You can read Brad's blog at blog.bradapp.net.

About the author

Steve Berczuk's picture
Steve Berczuk

Steve Berczuk is an engineer and ScrumMaster at Humedica where he's helping to build next-generation SaaS-based clinical informatics applications. The author of Software Configuration Management Patterns: Effective Teamwork, Practical Integration, he is a recognized expert in software configuration management and agile software development. Steve is passionate about helping teams work effectively to produce quality software. He has an M.S. in operations research from Stanford University and an S.B. in Electrical Engineering from MIT, and is a certified, practicing ScrumMaster. Contact Steve at steve@berczuk.com or visit berczuk.com and follow his blog at blog.berczuk.com.

About the author

Steve Konieczka's picture
Steve Konieczka

Steve Konieczka is President and Chief Operating Officer of SCM Labs, a leading Software Configuration Management solutions provider. An IT consultant for fourteen years, Steve understands the challenges IT organizations face in change management. He has helped shape companies’ methodologies for creating and implementing effective SCM solutions for local and national clients. Steve is a member of Young Entrepreneurs Organization and serves on the board of the Association for Configuration and Data Management (ACDM). He holds a Bachelor of Science in Computer Information Systems from Colorado State University. You can reach Steve at steve@scmlabs.com.