DekGenius.com
Previous Section  < Day Day Up >  Next Section

Recipe 6.9 Updating Your Code from a CVS Repository

6.9.1 Problem

You want to update your local code with the code in a CVS repository.

6.9.2 Solution

Right-click the file, and select Team Update, then resolve any conflicts. Alternatively, if you just want to replace your version with what's in the CVS repository, right-click the file and select Replace With Latest From HEAD.

6.9.3 Discussion

For example, say that someone checked out your code and changed this line:

public static void main(String[] args)
{
    System.out.println("No problem.");
}

to this:

public static void main(String[] args)
{
    System.out.println("No problems at all.");
}

When she makes these changes in his version of Eclipse, a > character appears in front of files that haven't yet been committed, as shown in Figure 6-9.

Figure 6-9. Outgoing changes ready
figs/ecb_0609.gif


When she commits her changes, the latest version of GreetingClass.java in the CVS repository changes from 1.1 to 1.2, as shown in Figure 6-10.

Figure 6-10. A new version in the CVS repository
figs/ecb_0610.gif


To update your code with the most recent version of the code in the repository (which is now Version 1.2, as stored by the other developer), right-click the project or file in your version of Eclipse and select Team Update. Doing so upgrades your version of the project's files to version 1.2—if there's no conflict.

If you've changed this line of code yourself to something such as this:

public static void main(String[] args)
{
    System.out.println("No problems here.");
}

there will be a conflict with the new line in the new version, version 1.2, of the file. Eclipse will mark that conflict by listing both versions in your code with some added CVS markup such as this:

public static void main(String[] args) {
<<<<<<< GreetingClass.java
    System.out.println("No problems here.");
=======
    System.out.println("No problems at all.");
>>>>>>> 1.2
    }
}

It's up to you to handle these conflicts in your code (Eclipse is not going to compile your code until the CVS markup has been dealt with and removed). Letting Eclipse handle updates like this is one way to handle updates from the CVS repository, but if the changes are substantial, it's best to synchronize with the repository, an issue we discuss in Recipe 6.10.

Note that if you just want to replace your version of a file with the latest version of the file in the main development stream for the project in the CVS repository, right-click the file and select Replace With Latest From HEAD.

    Previous Section  < Day Day Up >  Next Section