Page 156 -
P. 156
In addition to svn status, the programmer can use svn diff to see the specific changes that
have been made to each file. The svn diff command can take a file parameter to generate
a list of differences for that file; if no file is given, then it generates a list of differences for
every file that was changed. The differences are displayed using the unified diff format.
The svn revert command can be used to roll back changes. If the programmer issues that
command and gives it the filename of a file in the working copy, then that file is overwrit-
ten with a “pristine” copy that is identical to one in the revision that was checked out of
the repository.
Merge any changes made since the working copy was checked out
Before the changes can be checked in, the user should update the working copy. This causes
any changes made to the repository since the working copy was checked out to be changed
in the working copy as well. The programmer does this by using the svn update command.
Most of the time, the svn update will automatically merge any changes that were made.
But occasionally a programmer will have a change in his working copy that overlaps with
another change that was made to the repository since he checked out.
In the example above, Alice wanted to update cookies.txt and checked out r23 of the recipe
(which contained neither nuts nor M&Ms—see Table 7-1). She planned on adding nuts to
the recipe but, before she could commit that change to the repository, Bob added M&Ms
and committed r38 (see Table 7-2). When Alice attempted to commit her new revision
(see Table 7-3), Subversion gave her the following message:
$ svn commit –m "Added nuts"
Sending cookies.txt
svn: Commit failed (details follow):
svn: Out of date: 'cookies.txt' in transaction '46-1'
This told Alice that she needed to update her working copy in order to integrate any
changes by issuing the svn update command:
$ svn update
C cookies.txt
Updated to revision 46.
When Subversion detects a conflict, it updates the file and marks the conflict using a string
of greater-than and less-than signs. Table 7-8 shows the conflicts marked in cookies.txt after
the update.
TABLE 7-8. Subversion found conflicts in cookies.txt
2 1/4 cups flour 1 tsp baking soda 1/2 tsp salt
1 cup butter 3/4 cup sugar 3/4 cup brown sugar
1 tsp vanilla 2 eggs 2 cups chocolate chips
<<<<<<< .mine
1 cup chopped nuts
=======
1 cup chopped M&Ms
>>>>>>> .38
Mix butter and sugars. Beat until creamy. Add vanilla. Beat in
eggs, one at a time. Mix in rest of ingredients. Drop by
spoonfuls on cookie sheets. Bake at 350 degrees.
148 CHAPTER SEVEN