Search code examples
visual-studio-2010tfs-sdk

How to lock a branch using TFS API in TFS 2010?


Is it possible to lock a branch using TFS API in TFS 2010?


Solution

  • I am assuming you already know how to connect to TFS and get a specific workspace.

    With that said, you would use Workspace.PendEdit for this.

    Workspace.PendEdit Method (String[], RecursionType, String, LockLevel)

    The enum LockLevel is defined here:

    LockLevel Enumeration

    This acts the same as the UI if you were to right-click inside of TFS on the branch itself and perform the lock.