views:

107

answers:

7

I'd like it so when I check out a file no one else can edit it until I check it back in. Is there a version control system that allows me to do this? I currently use Subversion and I know it has the 'lock' feature but I want it to do that automatically without me having to request it on each file I'm working on.

A: 

Peforce does something close.

Trampas Kirk
A: 

Microsoft SourceSafe (yuck).

Otávio Décio
+3  A: 

There are lots of them.

Source Safe is notorious for not working any other way.

Serena Dimensions can be configured that way.

TFS will allow you to do an exclusive checkout.

Most source control systems will allow you to do this, some are built that way, other have the functionality in case it is needed.

However, if you are working in a team, doing this will only hurt progress. Being able to have many people work on the same file at one time is not only a time saver but is more efficient use of resources and speeds work along. You should only use exclusive lock in special circumstances, where you really can't have anyone else work on the file.

Oded
Source Safe supports both methods as of SourceSafe 2005.
Nissan Fan
I originally used source safe as version control so thats where i got the idea from. I liked it better that way knowing i wouldnt have to worry about my code getting overwritten or lost in merging somewhere. After reading the comments in here though, it seems that it works best for everyone to not lock the files. Generally, id be working in a small team of 3 or so, so I think the locking wouldnt hold us back that much.
chadley
@chadley: I've been in small teams where locking was a problem. I suspect it depends more on the nature of the work; new development is probably more separable by locking than urgent bug fixes. And, yes, merging VCSs can be scary at first and take some getting used to. Just try one sometime if you can, and see how you like it after you've used it for a month or so. That's what convinced me.
David Thornley
+2  A: 
  • CVS

  • Clearcase

--

Typically modern VCSs seem to deprecate the lock model of development, preferring a merge model.

edit: SVN merging is - in my opinion - broken. Once you've used ClearCase/Mercurial/git merging... you'll learn that fast. :)

Paul Nathan
CVS operates in a merging role by default. You can put advisory locks in effect if you like, and it is possible to use the older RCS functionality to lock a file, but I don't even remember if that's available except as an admin tool.
David Thornley
@David: Agreed. But CVS *does* have lock functionality of a sort(reserved checkouts), which is why I added it. `cvs admin -l` I gather.
Paul Nathan
+4  A: 

You can do it in subversion. I'd recommend that you dont and instead learn how to merge. Here's some more information:

http://svnbook.red-bean.com/en/1.2/svn.advanced.locking.html

NickAtuShip
+1  A: 

The old IBM "CMVC" tool works that way, I think. It makes me feel uncomfortable and vaguely sad to think about that however.

Pointy
+1 for being funny AND sad.
Ken Liu
A: 

RCS uses locks as the main approach to managing edits. You check out the file, and if you intend to edit it, you lock it. You can force an override on someone else's lock, but if you do, you clobber their changes. See for example this best-practices discussion for more info.

ire_and_curses
RCS is also one of the oldest VCSs around. It operates on a per-file basis, and neither easily supports a central repository nor offers DVCS-style merging.
David Thornley
@David Thornley: I'm not advocating RCS vs a modern VCS, but it does answer the question - if you want locking as a major feature by default, there it is. Others have already pointed out that if you're looking for locking as a key feature, you're probably solving the wrong problem.
ire_and_curses