Using Watches

A watch is the conventional name for CVS's feature to notify users of the repository whenever a file has been changed or a developer has started editing a file. The usage of watches requires that the file $CVSROOT/CVSROOT/notify has been set up properly. This is not discussed here; if you need further information on the setup from the administrator's point of view, read one of the books listed in the appendix.

Cervisia's main support of watches are six menu items.

In order to add a watch to one or several files, use AdvancedAdd Watch.... In the dialog you get, you can choose to get notified for any of the types of events that CVS supports. For example, if you only want to get notified when a file is committed, check the boxes Only and Commits. If you want to get notified about any event related to the marked files, check the box All. The command line used when you accept the dialog is

cvs watch add -a commit file names

or with a similar option, depending on the events you chose to watch.

If you are not interested in some files anymore, you can remove your watches on them. To this end, use AdvancedRemove Watch.... In the dialog you get here, the same options are offered as in the form you filled out when adding the watch. When you confirm this dialog, Cervisia issues the command

cvs watch remove file names

possibly with an option -a for the chosen events.

Finally, you can get a list of the people who are watching a couple of files. Choose AdvancedShow Watchers. Using this menu item will result in a command

cvs watchers file names

In the normal usage scenario of CVS, each developer works separately in his checked out sandbox. When he wants to modify some file, he can just open it in his editor and start working on it. Nobody else will know about this work until the file gets committed.

For some developer groups, this is not the preferred model of cooperation. They want to get notified about someone working on a file as soon as he starts with it. This can be achieved by some further CVS commands. Before you start editing a file, select it in Cervisia's main window and choose AdvancedEdit Files. This will execute the command

cvs edit file names

This will send out a notification to everyone who has set an edit watch on this file. It will also register you as an editor of the file. You can obtain a list of all editors of a certain file by using AdvancedShow Editors. This is equivalent to typing on the command line

cvs editors file names

An editing session is automatically ended when you commit the affected file. At that moment, an unedit notification gets sent out to all people who have registered a respective watch on the file. Of course, sometimes you may not want to commit the file, but abort the editing session and revert to the previous version of the file. This is done by using AdvancedUnedit Files. Note that Cervisia will not ask you for confirmation; that means if you use this menu item, all your work done since you used AdvancedEdit Files will be lost. Precisely, Cervisia uses the command line

echo y | cvs unedit file names

So far, we have only discussed the case where edits and unedits are used voluntarily be the developers. In addition CVS supports a model which enforces the usage of these commands. The responsible command to switch to this model is cvs watch on which we will not explain further because it is mostly used by the administrator of the repository. However, the important point from the developer's point of view is that when the project enforces edits, working copies are checked out readonly. That means you cannot edit a file by default (unless you use tricks like chmod). Only when you use AdvancedEdit Files, the file becomes writable. It is made read-only again when you commit the file or use AdvancedUnedit Files.

Cervisia's editor interface helps you with projects that enforce watches also in a different way. If you just started an editor with a readonly file by double-clicking on it or by using FileEdit, you would not be able to save your modifications later. This has of course a reason: Whenever you want to change a file, you should run cvs edit before, so that all people watching the file get a notification that you are working on it.

In such a case, it is advisable to check the option SettingsDo cvs edit Automatically When Necessary. Now, whenever you edit a file by double-clicking it, Cervisia will run cvs edit before the editor is actually executed. Then you can edit your file as usual. When you have finished your work, commit your files, and the committed files are read-only again.