SVN and TortoiseSVN Combat: File Lock Details

Source: Internet
Author: User
Tags version control system tortoisesvn

Hard canton: "SVN and TortoiseSVN Combat" series has been written eight, this is the end of the series, the entire collection of TORTOISESVN is easy to overlook in the SVN part of the detailed, to the main skill.

This article explains the use of TortoiseSVN to lock and unlock files, which involves the SVN attribute knowledge previously described, about attributes can be turned to "SVN and TortoiseSVN Combat: Properties of the Artifice (a)", " SVN and TortoiseSVN Combat: Artifice (ii) of attributes.

Locking and unlocking operations are very useful for non-consolidated files such as binaries, slices, sounds, dynamic libraries, and so on in the project, which prevents annoying conflicts, but the get lock in TORTOISESVN does not actually meet the needs and cannot obtain exclusive access to the file before editing. This is also the article to combine attributes to explain the file lock-up reasons.

Summary of the content of this article:

1, version control system locking strategy: optimistic locking, strict lock;

2, use TORTOISESVN to obtain the lock and release lock;

3, the use of attributes, the file is set to read-only;

4, the proposal about the lock;

1, version control system locking strategy: optimistic locking, strict lock

In order to avoid multiple people at the same time to the same file changes in the mutual coverage, the version control system must have a set of conflict processing mechanism.

There are two ways to resolve conflicts: optimistic locking and strict locking.

Strict lock: All checked out files are read-only, any modifications to the file must obtain the file lock, if the other person does not have the lock of the file, then the version control system will authorize your file lock, and set the file to be editable.

Optimistic lock: All checked out files are read-write, the file changes do not have to get the file lock, when you modify the file check-in, you will first ask you to update the local file, the version control system will not overwrite your local changes, but will let you merge conflict check-in.

SVN uses an optimistic locking strategy, and a version control system like TFS allows you to select a lock policy.

Optimistic locking may have a higher probability of conflict than a strict lock-up, but allowing team members to edit files at any time has great collaboration efficiency.

SVN also provides a strict locking method for files such as non-consolidated binaries or for certain files and directories, which is the locking unlock operation.

2, use TORTOISESVN to obtain the lock and release lock;

SVN by default, all files are not locked, as long as anyone with commit permission can submit any file at any time. Others will update their working directory regularly, and everything that changes in the library will be merged with the local one.

If you get a lock on a file, then only you can submit the file. Other users ' submissions will be rejected until you release the lock.

Get Lock:

Select the file you want to get locked, and then right-click on the TortoiseSVN get lock, the lock window will pop up:

A good habit is to enter the reason for acquiring a lock in the red callout position each time the lock is acquired.

Release Lock:

There are two situations in which a lock is released:

1. Select the file you want to release the lock, then right click on TORTOISESVN release lock;

2, TORTOISESVN in order to ensure that you do not forget to release the lock, in the Submission dialog box, always show the locked file, and always by default is selected. If you continue to commit, the lock in the selected file is removed, even if you have never modified it. You can use commit on the directory where the file is locked and open the Commit dialog to verify it.

If you do not want to release the lock on the file, you must uncheck it.

What's the problem?

If the actual operation, using the TORTOISESVN get lock to lock, you will find and not as you expected, the file implementation of the strict lock, this article will not have to write.

What's the problem? After locking the file with TortoiseSVN's Get lock, other users do not know that you have locked the file, immediately they check out the latest version, still be able to modify the file locally, the file is still readable and writable state.

This is a file that has get lock on the other member's computer and can see no difference in state with other files:

This makes no sense, others will still change your locked files, only when they check in to find that the file has been locked:

Under this lock operation, team members need to check the file lock status periodically, and can use TORTOISESVN's check for modifications:

3, the use of attributes, the file is set to read-only;

Other members can still be locally modified after being locked because SVN is adopting an optimistic locking strategy.

If we want to take a strict locking policy on a file or a directory, more specifically: All files are read-only by default, you need to acquire a lock before the file is modified, and only if someone else does not have a lock, you can lock the file and modify it.

To implement strict locking, you need to use the Svn:needs-lock property of SVN.

Right-click on the file or directory where you want to take a strict lock, use the TORTOISESVN Properties menu, click News New Property, select Needs-lock:

Set to locking required, check-in property modification, you can find that the file's icon state has changed and becomes read-only:

When the Svn:needs-lock property is set, a strict lock policy is actually taken on the file, and any modification to the file must first lock the file with TortoiseSVN's Get lock.

4, about the lock recommendations

For binary files in the project, slices, sounds, dynamic libraries, etc., you can set the Svn:needs-lock attribute uniformly on the directory, avoid conflicts on these files, and waste time to resolve conflicts.

Conclusion: There are nine articles in this series, and the technique of SVN is basically introduced comprehensively, and we hope to help you. If you want to learn SVN system, you can read the "version control of the road" this book, the contents of this series and the content of the book is not completely repeated, more focused on the actual combat and technical content, and finally hope that in the project development can be correct, reasonable use of SVN.

SVN and TortoiseSVN Combat: File Lock Details

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.