< Zurück | Inhalt | Weiter >

10.2.4 Integration with CVS

NetBeans comes with a built-in CVS client, which means that you don’t need to install any additional features in NetBeans to get it to talk with a CVS server. It has all it needs to check out and commit files from and to a CVS repository. NetBeans can be configured to use external (i.e., outside of NetBeans) CVS commands, but you likely won’t need to do that.

What you will need to do, however, is tell NetBeans that the files you are using are under CVS control. You do this by mounting the filesystem not as just a regular filesystem, but as a CVS filesystem. In the Explorer window, go to the Filesystem tab if you are not already there. On the Filesystem icon, right-click your mouse, and from the pulldown menu choose Mount, then Version Control, then CVS (Figure 10.6). What follows will be a wizard-like series of dialogs which you will fill in to describe the type and location of the CVS repository with which you want to work. Those choices and values are specific to your installation, so we’ll leave that for you to figure out with your network administrator or whoever has set up your repository.

Once mounted, the CVS filesystem’s files will look much like any other filesystem you have mounted—except that the files will show, via their icon, when they have been modified and need to be committed, and will show the version number in parentheses after the filename. The other difference is that there is now a CVS command on the pulldown menu (Figure 10.7) that appears when you right-click on one of the filenames (or on its tab in the Edit view).

Move your mouse over the CVS command; an additional pulldown menu appears (Figure 10.8). If you’ve used CVS at all, then you’ll recognize the list of commands in the cascaded menu. There are the Commit, Update, Diff, Log, Status, and Checkout commands that you are familiar with. The first item, Refresh, is likely unfamiliar, though. Not being a CVS command (it’s not part of the command-line syntax), it is a way for you to tell the IDE to


Figure 10.6 Mounting a CVS filesystem


Figure 10.7 Right click on a CVS file

reconsider what it thinks about the CVS-related information displayed in its icons and the parenthetical text.

If you click on a folder instead of a single file, then the Refresh command will be followed by Refresh Recursively which will do a refresh on each file

from there on down the tree.


Figure 10.8 Cascaded menu with CVS commands

Using the integrated CVS is much like using the command line. If you want to see the changes that you’ve made (before committing), use the Diff command. A window will appear showing the two different versions and coloring the lines that have been added, deleted, or changed.

When you need to commit your changes, click the filename, then right- mouse your way to Commit. A dialog window will appear for you to type in the comment that you want to be associated with this change. (This comment will appear in the Log command display).

To incorporate the changes others on your project may have made on the file, use the Update command. A dialog box will display the CVS output showing what was updated and if any merge conflicts occurred. (See Chapter 8 for more on this.)

The CVS commands in the menu, as we’ve described them so far, don’t allow you to add any options to the commands. They just run with the defaults. What if you want to use some of the options available on the CVS command line? Then hold down the Ctrl key just before your make your CVS choices. You should see an ellipsis (“...”) appear after each CVS command for which you can now select options (Figure 10.9).

Of course one of the great things about knowing the command-line ver- sion (see Chapter 8) is that you’re not limited to what the GUI tools will do for you. If you can’t find the option you want, just go back to a window with a shell prompt, cd into the appropriate directory in your source tree, and type the CVS command by hand. As noted earlier, NetBeans is smart enough to


Figure 10.9 Cascaded menu after choosing CVS with Ctrl pressed

catch on to the changes made outside of NetBeans to its files, though you may need to do a Refresh, as described above.