13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8.2 Source C<strong>on</strong>trol: Whys and Hows193Kwan goes to commit his modified versi<strong>on</strong> of Account.java to the repository,he is notified that Account.java has been changed since his copy was checkedout, and the commit attempt fails. So Kwan does an update which merges the1.8 versi<strong>on</strong> of Account.java in with his modified 1.7 versi<strong>on</strong>. If all goes well,the resulting file will be a 1.8 versi<strong>on</strong> of Account.java which includes Kwan’snew changes in the right place(s). Kwan just commits this to the repository,and Account.java then stands at versi<strong>on</strong> 1.9.Note that cauti<strong>on</strong>ary phrase “if all goes well.” The merge will work if Tiand Kwan have each modified different parts of the same file. If all Kwan didwas add a new method, it would merge just fine. But what if they both makechanges in the same regi<strong>on</strong> of the source file? It is up to the programmer toresolve such c<strong>on</strong>flicts and commit the source <strong>on</strong>ce again.In such a situati<strong>on</strong>, CVS does what it can to help out. There is an exampleof a merge c<strong>on</strong>flict later in this chapter. But such c<strong>on</strong>flicts require humaninterventi<strong>on</strong>.Merging of c<strong>on</strong>flicts is, undoubtedly, a very manual process, but you willbe surprised by how infrequently you need to do this. Most changes will bemerged clean with no manual interventi<strong>on</strong> required. That’s probably becausemost often, when two or more programmers are modifying the same file, theyare modifying different secti<strong>on</strong>s of it.With merging, you have the ability to incorporate other developer’schanges into your versi<strong>on</strong> of the source without the fear of losing your changes.No <strong>on</strong>e’s changes get lost, no <strong>on</strong>e’s files get “stepped <strong>on</strong>.”8.2.1 SetupBefore you can use CVS to track your sources, you need to initialize a repository.You can use this repository for several different projects, so you <strong>on</strong>ly needto do this setup <strong>on</strong>ce.There are two different ways to c<strong>on</strong>nect to a repository—directly <strong>on</strong> afilesystem, or indirectly over a network. We will use the simpler filesystemmechanism for this discussi<strong>on</strong>. The network c<strong>on</strong>necti<strong>on</strong>s are described in thereferences at the end of this chapter.In order for CVS to know where the repository is located and how toc<strong>on</strong>nect to it, it looks for an envir<strong>on</strong>ment variable called CVSROOT. You canassign a value to CVSROOT from the command line each time you create a CVSproject, or for more c<strong>on</strong>venience, you can set it in the shell startup script(e.g., .bashrc) so that its ready all the time. The CVSROOT value is really <strong>on</strong>ly

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!