Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1

(^108) CHAPTER 8 ■ TESTING, DEPLOYMENT, AND CONTINUOUS INTEGRATION


Committing Changes and Resolving Conflicts.


Now that the files are under revision control, you can change them as required. When you want
to save your changes to the repository, you need to commit them. To determine if you have any
changes to commit, use the svn status command:

> echo changed > newfile.txt
> svn status
M newfile.txt

This example shows that newfile.txt has been changed. The M beside the file indicates
that all local file changes have been merged with changes from the repository. Therefore, the
changes should be committed.
If you don’t like your changes, you can restore the old file with the svn revert command:

> svn revert newfile.txt
Reverted 'newfile.txt'
> cat newfile.txt
test

Next, to simulate another developer working on the project, create a second checkout in
your home directory.

> svn co file:///usr/local/svn/myfirstrepo ~/myfirstrepo2
A /home/user/myfirstrepo2/newfile.txt
A /home/user/myfirstrepo2/index.html
Checked out revision 2.

Then add some content to newfile.txt in the myfirstrepo2 directory:

> echo newdata >> newfile.txt
> svn commit
Sending newfile.txt
Transmitting file data.
Committed revision 3.

Return to the myfirstrepo directory, and do not choose to update it. Open newfile.txt,
and you will notice that the changes from the other checkout have not yet been reflected in this
file. Now make a similar, but different, change to the same line of the file in this checkout, and
try to commit it. You will get an out-of-date error, indicating someone else has changed the file.
You must always have the latest version of the file to commit changes. Running an update now
will result in a conflicted state, because you have changed the same line in both checkouts:

> echo alternativedata >> newfile.txt
> svn commit
Sending newfile.txt
svn: Commit failed (details follow):
svn: Out of date: 'newfile.txt' in transaction '3-1'
> svn update
C newfile.txt
Updated to revision 3.

McArthur_819-9C08.fm Page 108 Friday, February 22, 2008 9:06 AM

Free download pdf