Use the lock Command with Discretion

- J.D. Meier, Jason Taylor, Alex Mackman, Prashant Bansode

Use the lock command sparingly because locking a file while you work on it can lead to bottlenecks in the development process by preventing other people from working on the same file at the same time. You should only lock a file while editing it if you are concerned that there will be a conflict resulting in a complicated manual merge operation. Where possible, prefer shared checkouts by selecting the lock type None when you check out the file.

The following are common scenarios where using a lock is appropriate to avoid conflicts:
  • You are modifying a binary file format, such as an image or a document that cannot be easily merged.
  • You are making such widespread changes to a file that any other developer working on the same file would be very likely to make changes to the same lines as you.

If you want to avoid any possibility of conflicts, use a checkout lock, which prevents other people from checking out and checking in the same file. If you do lock a file, notify your teammates when you lock a file and tell them why you are doing so and how long your work on the file is likely to take. Also let them know when you remove the lock and check your changes back in.

You specify your lock type when you check out a file for editing, or you can explicitly lock a file.

To lock a file while checking it out
  1. In Source Control Explorer, right-click the file and then click Check Out for Edit.
  2. Specify your lock type: None, Check Out, or Check In.
  3. To explicitly lock a file, right-click the file, click Lock, and then select the Check Out or Check In lock type.

Note that unlike Microsoft Visual Source Safe® (VSS) behavior, checking out a file does not implicitly get the latest version. Prior to locking a file, make sure that you have the latest version in your workspace by clicking Get Latest Version.

Additional Resources

Last edited Jul 26, 2007 at 9:52 AM by prashantbansode, version 3

Comments

No comments yet.