Version control systems can be used to organize any collection of documents, including NetBeans project files.
This presentation describes how to use Subversion to set up a repository, and how to use NetBeans to access it. For project teams, one team members sets up a subversion repository and a server. This is only done once at the begining of team coding efforts.
After the server and repository are set up, all team members use a subversion client that communicates with the server to access the repository.
Subversion is an Apache Software Foundation project.
O'Reilly publishes a free, online book Version Control with Subversion.
The Subversion server program is called svnserve.
One of the members of your team could run the server on their own server machine if they have one. This would require that the machine be:
Or, your team can make use of the CS Department file server, an approach that will be described in this section.
All CS and CIS majors have disk space provided by the CS Department.
This space resides on a file server with host name ukko.d.umn.edu, and where Subversion is installed.
Once your team has started a server and configured a project repository, you will be able to access it through NetBeans and a subversion client.
It is important that the same person perform these steps, because the server process and repository folder must be owned by the same user.
In the descriptions that follow, suppose the person setting up the repository has UMD username smit0012.
You will need to be connected to the internet, and you will need to know your UMD X.500 username and password.
If you are using linux/unix, open up a terminal window and do:
ssh smit0012@ukko.d.umn.edu
If you are using Windows, use an ssh client like putty. After successfully logging in, you will be connected to ukko via a command-line interface.
cd /home/csugrads/smit0012
Create the repository, in this case called cs4531project:
svnadmin create cs4531project
Make the repository folder publicly inaccessible:
chmod 700 cs4531project
Go to the configuration folder for the repository just created and
observe the configuration files (note that system responses are shown
in green):
cd cs4531project/conf; ls
authz passwd svnserve.conf
You will need to edit svnserve.conf and passwd.
username = passwordwhere username and password are made up by you for your team members to share when accessing the repository. (Apparently digits are not allowed in either.) For example:
bill = billsecretSince passwords are stored in clear text you should make sure that the passwd file is not readable by others (giving the repository 700 permission sees to this). Q: When a user accesses the repository remotely with a password, how is it not transmitted over the network? A: The server uses CRAM-MD5 authentication, in which the user's password is hashed before sending. The same hash is performed on the stored password, and the hashed results are compared during authentication.
Open the file svnserve.conf and scan through it. The lines that begin with a sharp sign ("#") are comments. You will see some uncommented lines containing nothing but a name enclosed in brackets such as "[general]". These lines begin sections of the configuration file. A section ends at the beginning of the next section or at the end of the file, whichever comes first. You should add thefollowing lines at the end of the "[general]" section:
anon-access = none auth-access = write password-db = passwdThese indicate that:
Since each team will have its own server instance, each instance will have to run on its own port. You can use any free port from 1000 to 65535. To avoid having to try several different ports I suggest you try port numbers from the following table with x ranging from 0 to 9. You will probably be successful on the first try.
Team | Port |
---|---|
1 | 901x |
2 | 902x |
3 | 903x |
4 | 904x |
5 | 905x |
svnserve -d --listen-port=9010The -d option runs the server in daemon mode, which means it runs in the background and will continue to run when smit0012 logs off of ukko.
If you see the following message try again with the last digit of the port number incremented.
svnserve: Can't bind server socket: Address already in use
ps aux | grep svn
smit0012 18386 0.0 0.0 98536 1128 ? Ss 15:34 0:00 svnserve -d --listen-port=9010
smit0012 18388 0.0 0.0 7624 896 pts/2 R+ 15:34 0:00 grep svn
Here the process id is 18386. Now kill the process and confirm:
kill 18386; ps aux | grep svn
smit0012 18440 0.0 0.0 7624 916 pts/2 S+ 15:39 0:00 grep svn
After the repository is set up any authorized user can access it from any client machine that has a Subversion client installed, by connecting over TCP/IP.
To get a Subversion client, you can go to the Subversion webpage and find binaries for most platforms.
Some Linux distributions provide package managers that make it easy to get and install Subversion (for example, Ubuntu's Synaptic Package Manager).
This section describes how to use a subversion client to access your repository.
svn import ... Put files into the repository for the first time svn checkout ... Get files from the repository for the first time svn update ... Get changes to files others have checked out svn commit ... Commit changes to checked out files back into the repository ... etc.
These commands are documented in the free Subversion book.
Or you can let NetBeans make the calls for you. We will describe this approach next.
Note that NetBeans will assume you have a Subversion client installed.
URL Component | In Example |
---|---|
Prefix | svn:// |
Host | ukko.d.umn.edu |
Separator | : |
Port | 9010 |
Path | /home/csugrads/smit0012/cs4531project |
==[IDE]== Feb 24, 2012 12:23:21 PM Preparing Commit... ==[IDE]== Feb 24, 2012 12:23:21 PM Preparing Commit... finished. ==[IDE]== Feb 24, 2012 12:25:10 PM Committing... commit -m "My first modifications to index.xhtml" .../MyProject/web/index.xhtml Sending .../MyProject/web/index.xhtml Transmitting file data ... Committed revision 3. Revision: 3 Author : team1 Date : Feb 24, 2012 12:13:56 PM My first modifications to index.xhtml ==[IDE]== Feb 24, 2012 12:25:12 PM Committing... finished.
Committing changes to an entire project is not recommended as it may commit changes to project configuration (.xml) files that can cause conflicts among the checked out projects.
==[IDE]== Feb 24, 2012 1:31:25 PM Updating "web" update ... U .../MyProject/web/index.xhtml Updated to revision 4. ===== File Statistics: ===== Updated: 1 ==[IDE]== Feb 24, 2012 1:31:26 PM Updating "web" finished.
This line is modified by Jones.Meanwhile someone has recently committed a change to index.xhtml in the repository such that line 9 there reads:
This line is modified by Smith.Now you will not be able to commit your change without updating, but when you update you receive the warning: Now you have to resolve the conflict manually.