PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 17 ■ VERSION CONTROL WITH SUBVERSION

$msgSystem = ReceiverFactory::getMessageSystem();
$email = $context->get( 'email' );
$msg = $context->get( 'pass' );
$topic = $context->get( 'topic' );
$result = $msgSystem->dispatch( $email, $msg, $topic );
if (! $user ) {
$this->context->setError( $msgSystem->getError() );
return false;
}
$context->addParam( "user", $user );
return true;
}
}


All I have done here is to add a comment to simulate an addition to the code. Meanwhile, users
begin to report that they are unable to use the feedback mechanism in the system. I locate the bug in the
same file:


//...
$result = $msgSystem->dispatch( $email, $msg, $topic );
if (! $user ) {
$this->context->setError( $msgSystem->getError() );
//...


I should, in fact, be testing $result, and not $user. I could fix this here, of course, but the users
would not see the fix until my experimental code is stable. Instead, I can create a branch of the project.
In fact, I would do this at the same time as creating the release tag.


$ svn copy svn+ssh://localhost/var/local/svn/megaquiz/trunk \
svn+ssh://localhost/var/local/svn/megaquiz/branches/megaquiz-branch1.0.0
-m'release branch'


Committed revision 10.


What’s the difference between this use of copy and the tag example from earlier? As far as
Subversion is concerned, absolutely nothing. I’m simply copying into the branches directory rather than
the tags directory. It’s my intention that makes the difference. I intend to commit to this copy, rather
than just to use it as a snapshot.
In order to work with my new branch I’ll have to check it out first. I need to fix the code as it stood at
the point of last release. I move out of the development project directory (so that my current working
directory does not contain a Subversion administration directory), and then check out the project.


$ cd ..
$ svn checkout svn+ssh://localhost/var/local/svn/megaquiz/➥
branches/megaquiz-branch1.0.0
\
megaquiz-branch1.0.0


A megaquiz-branch1.0.0/quizobjects
A megaquiz-branch1.0.0/quizobjects/User.php
A megaquiz-branch1.0.0/quiztools
A megaquiz-branch1.0.0/quiztools/AccessManager.php
A megaquiz-branch1.0.0/main.php

Free download pdf