/** * Execute an action * * @param string $sMessage The Message to show * @param array $aExpected The expected input - needs keys continue & abort * * @return AbstractAction */ public function execute($sMessage = '', array $aExpected = array()) { $bExecute = true; if (isset($this->_oProperties->skiponcontinue) === true and $this->_oProperties->skiponcontinue === true and $this->_oConfig->continue === true) { $bExecute = false; } if ($bExecute === true) { if ($this->_execute() === true) { $sMessage = empty($sMessage) === true ? self::MSG_CONTINUE : $sMessage; $this->_oNotifier->notify(\notifyy\Notifyable::INFO, sprintf($sMessage, $this->getName())); } if ($this->_oConfig->unattended !== true and ($this->isSuccess() !== true and empty($sMessage) !== true or isset($this->_oProperties->confirm) === true and $this->_oProperties->confirm === true)) { $this->_confirm($aExpected); } } return $this; }
/** * Run mergy * * @param array $argv * * @return int, exit-code * * @TODO Cleanup ! */ public function run(array $argv) { try { if ($this->handleArguments($argv) === false) { return self::SUCCESS_EXIT; } $sVersionControl = isset($this->_aArguments['config']->vcs) === true ? $this->_aArguments['config']->vcs : \Mergy\Revision\Builder::SUBVERSION; $oBuilder = new \Mergy\Revision\Builder($sVersionControl, new \Mergy\Util\Command()); $oAggregator = new \Mergy\Revision\Aggregator($oBuilder); $oAggregator->set($this->_aArguments); $bDiff = $this->_aArguments['diff'] === true ? $oAggregator::CREATE_DIFF : $oAggregator::SKIP_DIFF; $aRevisions = $oAggregator->run($bDiff)->get(); if ($this->_aArguments['all'] !== true) { $oRevisions = new \Mergy\Action\Merge\Revisions(); $aRevisions = $oRevisions->setup($aRevisions, $this->_aArguments['config'])->get(); unset($oRevisions); } $this->_aArguments['config']->mergeRevisions = $aRevisions; if ($this->_aArguments['list'] === true) { $sPrinter = $this->_aArguments['group'] === true ? \Mergy\TextUI\Printer\Builder::WRITER_GROUP : \Mergy\TextUI\Printer\Builder::WRITER_LIST; $oPrinter = \Mergy\TextUI\Printer\Builder::build($sPrinter, $this->_aArguments['formatter']); \Mergy\TextUI\Output::info($oPrinter->setRevisions($aRevisions)->get()); } else { $oAction = new \Mergy\Action($this->_aArguments['config'], $this->_oNotifier); $oAction->setup(); if ($this->_aArguments['diff'] === true) { $oAction->command('Diff'); } else { $oAction->pre()->merge()->post(); } unset($oAction); if ($this->_aArguments['config']->more !== true) { $this->_oMergeTracker->clean(); } } $this->_oNotifier->notify(\notifyy\Notifyable::INFO, self::FINISHED); unset($aRevisions, $oBuilder, $oAggregator, $this->_oNotifier); } catch (\RuntimeException $e) { \Mergy\TextUI\Output::error($e->getMessage()); return self::ERROR_EXIT; } return self::SUCCESS_EXIT; }
/** * Start rendering * * @param \notifyy\Collection $oNotifier * * @return $this */ public function render(\notifyy\Collection $oNotifier) { foreach ($this->_aRevisions as $oRevision) { $aDiffs = $oRevision->aDiffs; $this->_iCount = count($aDiffs); if ($this->_iCount > 0) { $oContainer = $this->_addContainer($oRevision); foreach ($aDiffs as $aDiff) { $this->_addDiff($oContainer, $aDiff, $oRevision); } } } $sFile = getcwd() . DIRECTORY_SEPARATOR . 'Mergy_diff_' . time() . '.html'; $this->_oHtml->saveHTMLFile($sFile); $oNotifier->notify(\notifyy\Notifyable::INFO, $sFile); return $this; }