You've probably noticed that the watch features are utterly dependent on the cooperation of all the developers. If someone just starts editing a file without first running cvs edit, no one else will know about it until the changes get committed. Because cvs edit is an additional step, not part of the normal development routine, people can easily forget to do it.
Although CVS can't force someone to use cvs edit, it does have a mechanism for reminding people to do so – the watch on command:
floss$ cvs -q co myproj U myproj/README.txt U myproj/foo.gif U myproj/hello.c U myproj/a-subdir/whatever.c U myproj/a-subdir/subsubdir/fish.c U myproj/b-subdir/random.c floss$ cd myproj floss$ cvs watch on hello.c floss$
By running cvs watch on hello.c, jrandom causes future checkouts of myproj to create hello.c read-only in the working copy. When qsmith tries to work on it, he'll discover that it's read-only and be reminded to run cvs edit first:
paste$ cvs -q co myproj U myproj/README.txt U myproj/foo.gif U myproj/hello.c U myproj/a-subdir/whatever.c U myproj/a-subdir/subsubdir/fish.c U myproj/b-subdir/random.c paste$ cd myproj paste$ ls -l total 6 drwxr-xr-x 2 qsmith users 1024 Jul 19 01:06 CVS/ -rw-r--r-- 1 qsmith users 38 Jul 12 11:28 README.txt drwxr-xr-x 4 qsmith users 1024 Jul 19 01:06 a-subdir/ drwxr-xr-x 3 qsmith users 1024 Jul 19 01:06 b-subdir/ -rw-r--r-- 1 qsmith users 673 Jun 20 22:47 foo.gif -r--r--r-- 1 qsmith users 188 Jul 18 01:20 hello.c paste$
When he does so, the file becomes read-write. He can then edit it, and when he commits, it becomes read-only again:
paste$ cvs edit hello.c paste$ ls -l hello.c -rw-r--r-- 1 qsmith users 188 Jul 18 01:20 hello.c paste$ emacs hello.c ... paste$ cvs commit -m "say hello in Aramaic" hello.c Checking in hello.c; /usr/local/newrepos/myproj/hello.c,v <-- hello.c new revision: 1.12; previous revision: 1.11 done paste$ ls -l hello.c -r--r--r-- 1 qsmith users 210 Jul 19 01:12 hello.c paste$
His edit and commit will send notification to all watchers of hello.c. Note that jrandom isn't necessarily one of them. By running cvs watch on hello.c, jrandom did not add herself to the watch list for that file; she merely specified that it should be checked out read-only. People who want to watch a file must remember to add themselves to its watch list – CVS cannot help them with that.
Turning on watches for a single file may be the exception. Generally, it's more common to turn on watches project-wide:
floss$ cvs -q co myproj U myproj/README.txt U myproj/foo.gif U myproj/hello.c U myproj/a-subdir/whatever.c U myproj/a-subdir/subsubdir/fish.c U myproj/b-subdir/random.c floss$ cd myproj floss$ cvs watch on floss$
This action amounts to announcing a policy decision for the entire project: "Please use cvs edit to tell watchers what you're working on, and feel free to watch any file you're interested in or responsible for." Every file in the project will be checked out read-only, and thus people will be reminded that they're expected to use cvs edit before working on anything.
Curiously, although checkouts of watched files make them read-only, updates do not. If qsmith had checked out his working copy before jrandom ran cvs watch on, his files would have stayed read-write, remaining so even after updates. However, any file he commits after jrandom turns watching on will become read-only. If jrandom turns off watches
floss$ cvs watch off
qsmith's read-only files do not magically become read-write. On the other hand, after he commits one, it will not revert to read-only again (as it would have if watches were still on).
It's worth noting that qsmith could, were he truly devious, make files
in his working copy writeable by using the standard Unix
cvs edit entirely
paste$ chmod u+w hello.c
or if he wanted to get everything in one fell swoop:
paste$ chmod -R u+w .
There is nothing CVS can do about this. Working copies by their nature are private sandboxes – the watch features can open them up to public scrutiny a little bit, but only as far as the developer permits. Only when a developer does something that affects the repository (such as commits) is her privacy unconditionally lost.
The relationship among watch add, watch remove, watch on, and watch off
probably seems a bit confusing. It may help to summarize the overall
remove are about adding or removing users
from a file's watch list; they don't have anything to do with whether
files are read-only on checkout or after commits.
off are only about file permissions. They don't have anything to
do with who is on a file's watch list; rather, they are tools to help
remind developers of the watch policy by causing working-copy files to
All of this may seem a little inconsistent. In a sense, using watches works against the grain of CVS. It deviates from the idealized universe of multiple developers editing freely in their working copies, hidden from each other until they choose to commit. With watches, CVS gives developers convenient shortcuts for informing each other of what's going on in their working copies; however, it has no way to enforce observation policies, nor does it have a definitive concept of what constitutes an editing session. Nevertheless, watches can be helpful in certain circumstances if developers work with them.