PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

CHAPTER 17 ■ VERSION CONTROL WITH SUBVERSION


A megaquiz-branch1.0.0/command
A megaquiz-branch1.0.0/command/Command.php
A megaquiz-branch1.0.0/command/CommandContext.php
A megaquiz-branch1.0.0/command/FeedbackCommand.php
A megaquiz-branch1.0.0/command/LoginCommand.php
Checked out revision 10.


I moved out of the megaquiz-trunk directory before checking out the branch. Now I have two
directories at the same level: megaquiz-trunk contains the trunk, and I’ll commit my risky but useful new
features here. In fact I’ll do that now:


$ cd megaquiz-trunk/
$ svn commit -m'added new risky dev on trunk'


Sending command/FeedbackCommand.php
Transmitting file data.
Committed revision 11.


megaquiz-branch1.0.0, on the other hand, is my bugfix branch. I’ll only commit defect fixes here. Here’s
my fix:
class FeedbackCommand extends Command {


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


I have changed

if (! $user ) {


to


if (! $result ) {


Now to commit

$ cd ../megaquiz-branch1.0.0/
$ svn commit -m'fixed bug'


Sending command/FeedbackCommand.php

Free download pdf