Veracity Q&A home login about faq

How do file locks work?

asked Jul 02 '12 at 09:49

Jeremy%20Sheeley's gravatar image

Jeremy Sheeley ♦

edited Jul 02 '12 at 09:50

Note that this information applies to Veracity 2.0 and later.

What is a Lock?

A lock is a promise given by a Central Server that means "Other Users that want to change the locked file on a particular branch will have to base their changes on Your changeset."

The players involved are:

  • You - the user that acquired the lock.
  • Central Server - a server that both you and Other Users push to.
  • Other Users - Everyone that isn't You.

Key phrases in the definition are:

  • locked file: Only files can be locked.
  • particular branch: Locks only apply to a single branch. Locking a file in one branch has no effect on other branches.
  • Your changeset: This is an important phrase. After you get a lock, the next commit operation that changes the locked file on that branch will mark the lock as complete, and associate the changeset with the end of the lock. All Other Users will be waiting for that changeset before they will be allowed to make changes to the locked file.

Your responsibilities in order to get the lock:

  • You must be attached to a branch which has exactly one head.
  • Your baseline must be set to the branch's head.
  • You must be able to push and pull from the central server.
  • The lock will automatically close when you commit a change to the locked file on the specified branch.

The Central Server's responsibilities while the lock is active:

  • Share the lock information on every push or pull that contacts the central server.
  • Reject any changes from Other Users made to that file on that branch.
  • When You push up your changeset, begin accepting Other Users' changes as well.

Impact on Other Users:

  • If the Other User has been informed of the lock (through a push or pull to the Central Server), then any commit which would violate the lock will fail with a "lock violation" error. If the commit happens before being informed of the lock, then no such error can occur.
  • If the Other User has already committed the violating change but not pushed it to the Central Server, a push operation will fail with a "lock violation" error.
  • A lock will not end for Other Users until they pull down Your changeset that closes the lock. They will then have to merge with Your changeset or update to Your changeset in order get the latest version of the locked file.

An Example

Time William (the traveler) Brodie (the locker) George (the double-checker)
11:00 William gets on an airplane, and can't contact the central server.
12:10 Brodie locks the file @/src/images/header.png in preparation for editing it.
12:15 George attempts to lock the file @/src/images/header.png. The lock operation fails, since Brodie has it locked.
12:20 William attempts to lock @/src/images/header.png, but the operation fails, since the central server can't be contacted. William decides to go ahead and risk changing the file without a lock. He commits his change as changeset def456.
12:30 Brodie commits changeset abc123, which contains his change to the locked file. On Brodie's machine, the file is now unlocked. Brodie does not push the changeset up to the central server yet.
12:32 George attempts to lock the file @/src/images/header.png. The lock operation continues to fail, since he does not have changeset abc123 yet.
12:45 William lands, and attempts to push up his changeset. The push operation fails, as it violates Brodie's lock.
12:50 Brodie pushes changeset abc123.
12:51 George pulls changeset abc123, updates to it, and locks the header.png file.
12:54 William tries to lock the file, but fails, since George has locked it.
12:56 George commits his change as changeset adbecf, and pushes it up.
1:00 William pulls changeset adbecf, and merges def456 with adbecf. He must manually change header.png to include his changes again. He commits and pushes.

answered Jul 02 '12 at 09:50

Jeremy%20Sheeley's gravatar image

Jeremy Sheeley ♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jul 02 '12 at 09:49

Seen: 1,076 times

Last updated: Jul 02 '12 at 09:50

powered by OSQA