Go [TFS] prevents multiple people from checking out and forcing check-out locks by default

Source: Internet
Author: User

When you use Visual Studio Team Foundation Server for source code editing, you can implement one of the following three types of locks on your code:

    • Unchanged-keep any existing lock
    • Check out-prevent other users from checking out and checking in
    • Check In-allow other users to check out prevent them from checking in

It seems that the concept of "check out" and "check in" locks are similar to the concept of "exclusive locks (exclusive locks, X)" and "shared locks (S)" in the database.

The following is a discussion of the two issues encountered in using the check in and check out locks, which are used in a somewhat antagonistic situation.

How do I turn off the multi-person checkout feature for TFS Source control?

When you do a "check out" of the code, you can choose one of the three locking measures mentioned above, the default is "Do not change", if you edit the code directly, it will be automatically checked out, and the default use of "Do not change" locking measures. This measure can cause a lot of collisions when multiple people are concurrently modifying the code. As a result, you might want to change the default options for TFS, forcing an "exclusive lock" on the checked-out code.

To do this, right-select the project---> Team Project Settings---> Source control, and view the following interface in the Checkout Settings tab of the popup dialog box:

"Enable multiple Checkout" is checked by default, we can remove it, and note that the "Enable get Latest version on checkout" option is not checked by default, so you can check it for convenience. ( Note: This setting affects the rollback version of the operation!) because the general rollback version action is: get the specified version-check-out-check-in-resolves the conflict while preserving the local version. )

When you cancel the option to enable multiple checkouts, you can only choose to apply an exclusive lock by default when you check out your code:


Ii. How to force the check-in check-out lock to be forced (editing)

Online Search for the key word of the problem, the results are mostly netizens "flying with the Wind" for Visual Studio Team Foundation Server written a maintenance note (see the reference list).

below for the TFS 2010 environment, write about how you should force the check-in check-out lock to work.

When we use TFS, we use the benefits of Sourcecontrol,sourcecontrol in TFS and I don't have to say it, but SourceControl has a more deadly flaw, is also sourcecontrol based on the work area of the problem caused by this mode, first SourceControl source management will create a workspace on each client machine, and then this work area map to the source folder on the server, when we check in, check out, Our source code will operate on the server to the client's workspace, which is no problem. But when we're using TFS, we're basically multi-person concurrent check-in, and TFS is designed to support check-in and check-out locks, and the default project group members don't apply any locks when they check out the project. Even if a project team member checks out the source project from TFS's SourceControl and joins a checkout lock or a sign like a lock, it doesn't matter, as long as the members of the project group follow the rules to put the project in the final check-in to SourceControl, the checked-out lock is automatically lifted.

The key question is if the members of the project group have gone to the coffee, or have a holiday, or the members of the project have left, but they have put a check-out lock on several files in the project before they leave, and if the next member of the project group wants to modify the locked file, Or if the administrator of TFS wants to delete the item in SourceControl, the problem arises. When we are working through Team Explorer, Team Explorer prompts for a check-out (in) lock, and then tells us which user, in which workspace, the lock was made. However, we are unable to pull out the checkout operation through the Team Explorer graphical interface, but only through the TFS command: Undo to forcibly withdraw the files that others have checked out.

First, the definition of the next workspace, a complete workspace should include "Workspacesample; [local domain \] User name, separated by commas (default is computer name) and user name. (the workspace definition in TFS 2008 also seems to include a user sequence number, which is "workspacesample; [the domain \] User name [: User number] ", do not know if TFS 2010 has canceled it. )

The steps to undo are as follows:

1, command line mode into the directory of the TF program (requires Administrator privileges)

CD C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE

If it is installed on a 64-bit operating system, it may be:

C:\Program Files (x86) \microsoft Visual Studio 10.0\Common7\IDE

2, using the TF workspaces command to find the user (here ZWT for example) the full definition of the workspace, where the/server parameters and/owner parameters are specified, if you do not specify the/owner parameter, the default user name is the user executing the command, that is, the lookup satisfies the "*;( Executes the command user name) "of the client area.

TF WORKSPACES/SERVER:HTTP://DQ311-SERVER:8080/TFS/OWNER:ZWT

The results of the above command execution are as follows (with TF workspaces command execution result comparison without any parameters)

3. View the user's pending changes (here to find the user Xyc pending changes in any workspace)

TF status/server:http://dq311-server:8080/tfs/workspace:*/USER:XYC

Execution results (Note that the file path and filename of the server are displayed in two lines):

4. Use the TF Undo command to force revocation of his check-out, with the following command:

TF undo/server:tfs server url/workspace:workspacesample; [domain \] User name [: User name Ordinal] $/path/file name

For example

TF Undo/server:http://dq311-server:8080/tfs/workspace:hy-pc;hy $/ctcs/tsags_team/testhy/program.cs

If you need to undo more items, you can use the wildcard character * instead of the file name, and the /recursive parameter (recursive), for example

TF Undo/server:http://dq311-server:8080/tfs/workspace:hy-pc;hy $/ctcs/tsags_team/*/recursive

Depending on whether the workspace being undone is located on the computer where the undo operation was performed, there are two things that result:

The first is that the work area of the undo is located exactly on the computer where the operation was performed, and the server and local code can be simultaneously undo, with the same effect as "undo Pending Changes" for the file in Visual Studio.

In more cases, the work area that is being undone is not on the computer where the operation was performed, and the operation can only be revoked on the server.

Then everyone can refresh your Team Explorer to see the locked file, after the undo operation, the user lock and suspend the file is all canceled, so you can be modified through Team Explorer, or delete more actions.

Note that in the second case, although the "checkout" status has been revoked, the file version is restored to the server version, but the local code modification of the workspace is not revoked, and the server code is inconsistent! That is, "version consistent, actual code inconsistency", in which case the "Get Latest Version" command on the workspace can not be updated to the server version, only through the "manually get the specified version" and other methods to resolve the conflict. (or you can wait for the next version of the code to update?) )

In addition, there are several places worth explaining (some may only apply to TFS 2008):

1, about the user name serial number

For example, if your user name is deleted, and then create a new user name with the same name, then the original user name and workspace Association is still there, so there will be two working area of the same name, WORK1; Wanggi:5, and Work1; Wanggi. This way, you can find the corresponding working area according to the different serial number when you are operating.

2. How to view the user name serial number

You can use this command to query the full details of the workspace (note that you have administrator privileges when executing commands):

TF workspaces/owner:*/computer:*/server:teamserver2/format:detailed

This command looks at the working area on all machines in the current server, including the name of the workspace, the ower of the workspace, and so on, so that the ID of your user can be seen.

3. What if the workspace does not exist? (e.g. work area reload system)

Basically no impact.

First use the command-line mode, display all the workspaces, and then find the tool you want to delete to delete, the command to delete the workspace is:

TF Workspace/delete Workspacename;workspaceowner

For example, to delete a user dq311 workspace on hy-pc, the command is:

TF Workspace/server:http://dq311-server:8080/tfs/delete hy-pc;dq311

Tips:

1, if there are other problems, the proposal can be TF/?, there will be detailed operation instructions come out;

2. Note that TF workspace and TF workspaces are two different commands.

Third, how to remove the code from source code control, so that it does not contain the VSSSCC extension file

This issue is not related to check-in and check-out locking. When you look at the information, you just see someone ask, and it's recorded here.

You can start by getting the latest version of the project to your local workspace, and then in Solution Manager, click the solution for the project, and then under source management settings under the File menu, disconnect the project from the local workspace.

Resources:

[1] Blog Park: Flying with the Wind: Team Foundation Server Maintenance Note One (forced check-in check-out lock)

[2] Http://stackoverflow.com/questions/13014746/tfs-2012-disable-multiple-check-out-not-working

[3] Force cancel check out of other members in TFS2008

This article fixed link: http://blog.xieyc.com/tfs-disable-multiple-check-out-and-force-to-undo-locking/| Xiao Xie's small station

Go [TFS] prevents multiple people from checking out and forcing check-out locks by default

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.