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

too (and also more frequent).

Codeline Locking Strategies

After seeing what great success Barney had improving the commit-preparation 'cycle time', Betty decided to try her hand at improving the safety and reliability of the Two-Phased Codeline-Commit protocol. This implied implementing or enforcing some kind of formal or informal codeline-locking strategy. The first thing she did was investigate how to make sure that the whole team follows the protocol:

Pre-Commit Validation : Before anyone attempts to commit, a query is made to see if Betty's workspace is already up-to-date with the latest state of the codeline. If it isn't, then the commit either fails, or else her workspace is automatically updated. The validation might also automatically rebuild/retest to check for any failures before allowing the commit to proceed (in which case the validation step essentially performs all the commit-preparation activities). Many version-control tools provide event-based validation 'hooks' out-of-the-box to script this (otherwise a commit-wrapper script may be used).

A Pre-Commit Validation can also initiate a locking protocol of some kind either before or after the commit-preparation activities.

Betty decides to implement Pre-Commit Validation so that it checks for and performs a Workspace Update (if needed) and initiates a locking protocol. She conducts her own research and found that the following Codeline Locking mechanisms commonly recurred in practice (listed in order of increasing formality and complexity):

Single Release Point : There is a single dedicated codeline integration work-area with a single monitor and keyboard (e.g., an integration machine/workspace). This lone integration resource is time-shared (used for only one person and change at a time), thereby ensuring commits are serialized.

Integration Token : Developers might be allowed to integrate their changes from any machine or workspace, but must first obtain a "token" to do so (and only one such token is available). The token might simply be a purely symbolic or physical artifact (e.g., a coin, a key, a rubber chicken or a purple barney-doll), or even something as informal as a verbal "catch phrase" like: "I've got the integration token!" being yelled out to the rest of the team. Or it might be as formal as implementing an exclusive lock on a specific file or object outside the codebase.

Codeline Write-Lock : Formally "lock" all or part of the codeline by having the version control tool prevent checkin to the codeline by anyone but the lock-holder (the person who "acquired" the codeline-lock for exclusive write-access). The lock-holder automatically relinquishes the lock after they are done committing their changes. They may also voluntarily release the lock anytime before then if they feel they need more time to reconcile any conflicts or failures since their last update.

Any implementation of a Codeline Write-Lock should include a mechanism for querying the lock to see who holds it, and a 'backdoor' mechanism for a codeline 'owner' or 'administrator' to release the lock in urgent circumstances. Sometimes an automatic or default 'timeout' is used to ensure the lock is never held for more than a predetermined maximum period of time.

A Codeline Write-Lock is typically implemented in one of two ways:

Full Codeline-Lock prevents the entire codeline (all files) from being written (checked-in) by anyone but the lock-holder. It is often implemented via a pre-checkout 'trigger' or 'hook' that looks for a 'locked' attribute/property that is somehow associated with the codeline.

Partial Codeline-Lock prevents codeline-checkin for only those files that are checked-out (were modified) by the lock-holder. This allows concurrent committing of non-overlapping changes at the expense of increasing the risk of an undetected conflict between change-tasks that had no files in common.

The implementation typically uses

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.