brentonstrine
brentonstrine

Reputation: 22742

How to lock files to avoid conflicts in Visual Studio

We use Microsoft Visual Studio 2010 and it allows us to check out and edit the same file simultaneously.

We frequently find that we have conflicts, and the merge tool is awful, inserting confusing things like mine <<<<<<<<< that is not very helpful.

Is there a way to make VS2010 disallow files from being edited if they're currently being edited by someone else? What about a better merge tool that lets you interactively choose how to merge it, instead of just pasting everything into the file?

Upvotes: 2

Views: 1290

Answers (2)

kprobst
kprobst

Reputation: 16651

You're not using Subversion correctly. The fact that you would mention that mine <<<<<< pattern used by SVN in conflict files tells me you're probably better off taking a couple of Subversion classes rather than trying to figure out how to lock files.

Upvotes: 1

David W
David W

Reputation: 10184

If you're using Subversion as your source control system, understand that it works on an edit-merge principal rather than the exclusive check-out model employed by tools like Visual SourceSafe. That means everyone can edit their working copies at the same time, and differences should be resolved by developers as they perform regular updates to their working copies. So, doing what you're asking runs a bit against the grain for how Subversion was designed to work.

That said, however, you can come fairly close to the SourceSafe check-out notion by "locking" a file. If you're using something like the Ankh Plug In for Visual Studio, you can right-click on a file in the Solution Explorer and choose "Lock."

You can also set a property on a file called "svn:needs-lock" which means that if you get a working copy of a file, its delivered read-only, and if you want to edit it, you must explicitly lock it.

EDIT: For a quick rundown of the Subversion locking philosophy, you might take a look here. Good luck!

Upvotes: 2

Related Questions