Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1
CHAPTER 8 ■ TESTING, DEPLOYMENT, AND CONTINUOUS INTEGRATION^109

Notice the C beside newfile.txt. This indicates a conflict. If you run ls on the directory,
you will see that three new files have been created:

> ls -1
index.html
newfile.txt
newfile.txt.mine
newfile.txt.r2
newfile.txt.r3

These files represent the conflict. The r2 file is the original file, the r3 file contains the
modification that was made in myfirstrepo2, and the .mine file is the local change. The .txt file
has also been changed and now contains both changes, to make resolving the conflict easier.

> cat newfile.txt
test
<<<<<<< .mine
alternativedata
=======
newdata
>>>>>>> .r3

Your job now is to make newfile.txt contain both change sets. Start by removing the <<<,
>>>, and === lines, and then add or remove changes to the file so that the result you want is
achieved. In more complex merges, you may wish to reject certain changes or rework both if
there is functional overlap. In this case, however, you want to keep the newdata change as well
as the local change. Your final file should look like this:

> cat newfile.txt
test
newdata
alternativedata

Next, you need to tell Subversion that you have resolved the conflict with the svn resolved
command:

> svn resolved newfile.txt
Resolved conflicted state of 'newfile.txt'

This deletes the three extra files. They have served their purpose by helping you to resolve
the conflict, and now are no longer needed.
The final step is to commit your resolved changes by calling svn commit:

svn commit
Sending newfile.txt
Transmitting file data.
Committed revision 4.

As you can see, using this process, developers are prevented from simply overwriting each
other’s code.

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

Free download pdf