PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

CHAPTER 17 ■ VERSION CONTROL WITH SUBVERSION


Updating and Committing


For the purposes of this chapter, I have invented a team member named Bob. Bob is working with me on
the MegaQuiz project. Bob is, of course, a fine and talented fellow. Except, that is, for one common and
highly annoying trait: he cannot leave other people’s code alone.
Bob is smart and inquisitive, easily excited by shiny new avenues of development, and keen to help
optimize new code. As a result, everywhere I turn, I seem to see the hand of Bob. Bob has added to my
documentation; Bob has implemented an idea I mentioned over coffee. I may have to kill Bob. In the
meantime, though, I must handle the fact that the code on which I am working needs to be merged with
Bob’s input.
Here’s a file called quizobjects/User.php. At the moment, it contains nothing but the barest of
bones:


<?php
class User {}
?>


I have decided to add some documentation. As you know from the last chapter, I should add file and
class comments. I begin by adding the file comment to my version of the file:


<?php
/**



class User {}
?>


Meanwhile, working in his own sandbox, Bob is keen as ever, and he has created the class comment:

<?php


/**



  • @package quizobjects
    */
    class User {}
    ?>


So we now have two distinct versions of User.php. At this time, the Subversion repository contains
only the recently imported version of MegaQuiz. I decide to add my changes to the Subversion
repository. This requires only one command, but two are advisable:


$ svn update quizobjects/User.php


At revision 1.


The update subcommand instructs Subversion to merge any changes stored in the repository into
your local document or documents. Before you commit your own work, it is good practice to first see if
anyone else’s changes conflict with your own, resolving any such conflicts in your own sandbox. The
command’s output indicates that no third-party changes need be applied.
Running update will apply any changes from the repository version of a file to your local copy. If you
omit the filepath, it will perform this operation on all files below your current location.

Free download pdf