tags:

views:

630

answers:

3

I have to use CVS in a project. So far in my whole working life, I have used only perforce and I do not know anything about CVS, I read the whole CVS manual but could not find how to do this :

In perforce, when you check out a file, you first have to do a p4 edit filename.C (telling the perforce system that you are intentionally about to edit this file with the intention of eventually submitting it)

In CVS, when I checked out a file by doing cvs co fileName.C, the file is already in ready-to-edit state.

What is the equivalent in CVS of what is the usual practice in perforce?

[I like the additional safety of having to first explicitly instructing the source control system of your intention of editing the file before you start doing so. This allows you to easily look at the files that you have edited, revert changes etc. In addition, you can also make temporary changes by explicitly editing files without first doing p4 edit fileName.C and later you know that you meant these only as temporary changes]

Many Thanks!

+1  A: 

CVS has an "edit" command, which informs the server that you are editing the file. This is honestly rarely used. There is no need to inform the system when you are editing a file, this can be easily determined by checking if the contents differ.

Subversion has the ability to lock a file, which may be more of what you're trying to do.

Distributed systems have no such notion, as there is no need for them to implement it (nor any possible way).

On a side note, the choice of CVS is puzzling. There are far better technologies for source control available now.

Yann Ramin
+2  A: 

You can do something like this:

cvs -r checkout ....

then when you want to edit a file, you must

cvs edit filename

Also, if you want commit to return the files to read-only, you must

cvs -r commit ...

Or, forget about the -r and just set the CVSREAD environment variable. Much easier!

From the CVS man page, in the global options section:

-r

Make new working files read-only. Same effect as if the $CVSREAD environment variable is set (see node Environment variables in the CVS manual). The default is to make working files writable, unless watches are on (see node `Watches' in the CVS manual).

Example:

$ cvs -r checkout baz
cvs checkout: Updating baz
U baz/file
$ ls -l baz/file
-r--r--r-- 1 rfeany None 13 Jul 17 21:08 baz/file
$ cvs edit baz/file
$ ls -l baz/file
-rw-r--r-- 1 rfeany None 13 Jul 17 21:08 baz/file
Rex
A: 

@Rex : Thanks. A combination of cvs -r and cvs editors and cvs watchers seems to be what I want.

@Theatrus: I would rather not use CVS but you do what you have to do.

Hello Amit, You can add a response to an answer by clicking "add comment" below an answer. There you can put the responses and the answerer will get notified. It would be best to delete this answer, and add these responses as comments to the answers from Rex and Theatrus.
Alex B