Adverts
Performing an import into CVS with NetBeans is now fairly simple assuming you know the correct magic words and have a sacrificial chicken on hand. Joking aside it is actually fairly easy now which is good because it used to be complete hell. The first stumbling block, for me at least, was the name. Why is it called an import when it appears to you that you are exporting? The reason is that you have to look at it from the point of view of the CVS server not your machine. This perhaps makes more sense if you imagine more than one person working on the project (maybe you are lucky enough to have more than one person working on your project). Anyway enough rambling on with how to do an import (this will of course include a checkout as well because with out a checkout the code can't be worked on). I am assuming that you have started a NetBeans project and have some material to import.
Step 1 - Prepare the Code
The first thing that you have to do is prepare the code. This basically involves removing anything that might have a binary file type so all images and jar files have to go. The reason you have to do this is because if you don't the binary files will be imported with a type of default (which is text). If the file changes CVS will attempt to do a textual diff of the file which is not only very wasteful but will also corrupt the file when it is checked out on another computer. I don't know why NetBeans doesn't automatically set the binary flag for files with known binary content and ask for others but we can't have everything (I suppose it might be a limitation of the CVS import function). Although he binary files have been removed here we will still be adding them to the CVS repository but that fun is saved for a later step.
Step 2 - Import the Code
Importing the code should be a fairly painless step but it causes me palpitations everytime I do it because it feels like I am giving my code to something I don't fully understand. From the menu choose Versioning --> CVS --> Import.... This will bring up a large dialog box which you have to fill in. The most sensible way to run a CVS server is in external mode where you contact and use it via SSH and that is the setup I am running. In the Directory to Import field enter the full path of the directory you want to add. Don't worry about removing the build and conf directories that are automatically skipped by NetBeans. So you will want to enter something like /home/username/development/myproject
Choose a server type of ext and set the various other settings. I can't help much with the other settings as they are very situation dependent but the tooltips are quite help full and it should be fairly obvious what is wanted in each box. The one that will fool you though is the Repository Directory field which defaults to . (dot). I consider this a bug because there is not way that you would want to import a project into the root of the CVS repository. Typically you should change this to the same name as your project which will cause a module with that name to be created in the CVS server.
The logging message, vendor tag and release tag have to be set but are fairly pointless. I set them to initial, vendor and release. Uncheck the Perform Checkout After Import checkbox. Although we will be doing a checkout of the source we will be doing it seperatly. The reason we will be doing it seperatly is because we want to checkout the source into the same location as it currently is. To do that you need to delete the source before the checkout.
Press Ok and cross your fingers. The versioning window should appear and report no errors (information does appear in the errors tab but it should just be a list of directories imported).
Step 3 - Checking Out the Code
Now that we have the code in the repository we need to check it out so that it can be managed under version control. Close the project if it is open and then from a file manager delete the project directory (I normally move it somewhere else and delete it later). Now, from inside NetBeans, select Versioning --> CVS --> Check Out which opens a dialog similar to the one for importing.
Set the working directory to the directory that will contain your project not a directory with the the name of your project. For instance, if your project is called myproject and you want it in /home/username/developement/myproject set the working directory to /home/username/development. Set the other settings and then, and this is important, select the Module(s) radio and enter in the text field the name of your project. If you forget to do this the whole CVS repository will be checked out and you will have to tidy it up (this is really annoying if you have a large CVS repository).
Press the Ok button and cross you fingers again. You code should be checked out into the workign directory.
Step 4 - Adding the Binary Files
Put the binary files back into the source tree and then add then through NetBeans as you would normally add a file just remembering to set the binary flag.