예제 #1
0
파일: Info.php 프로젝트: hpbuniat/mergy
 /**
  * (non-PHPdoc)
  * @see \Mergy\Util\Cacheable::_get()
  */
 protected function _get()
 {
     $sCommand = sprintf('svn log %s --xml -v -r %d', $this->_sRepository, $this->_iRevision);
     $this->_oCommand->command($sCommand)->execute();
     $this->_mCache = $this->_oCommand->get();
     if ($this->_oCommand->isSuccess() !== true) {
         $this->_mCache = '';
         \Mergy\TextUI\Output::error(sprintf(self::ERROR, $sCommand));
     }
     return $this;
 }
예제 #2
0
파일: Action.php 프로젝트: hpbuniat/mergy
 /**
  * Execute a step
  *
  * @param  string $sMethod
  * @param  array $aArgs
  *
  * @return Action
  */
 public function __call($sMethod, $aArgs)
 {
     if (in_array($sMethod, $this->_aSteps) === true and $this->_bProcess === true) {
         if (defined('VERBOSE') === true and VERBOSE === true) {
             \Mergy\TextUI\Output::info('Handling ' . $sMethod . '-Stack');
         }
         try {
             $this->_oActionHandler->{$sMethod}($this->_aRevisions);
         } catch (Exception $e) {
             $this->_bProcess = false;
             \Mergy\TextUI\Output::error($e->getMessage());
         }
     }
     return $this;
 }
예제 #3
0
파일: Revision.php 프로젝트: hpbuniat/mergy
 /**
  * Read modifications of a revision from a repository
  *
  * @return Revision
  */
 protected function _fetchFiles()
 {
     $this->aFiles = array();
     $oAggregate = $this->_oBuilder->getAggregator(Revision\Builder::AGGREGATE_FILES, array($this->sRepository, $this->iRevision));
     try {
         $this->aFiles = $oAggregate->get();
     } catch (Revision\Aggregator\Exception $oException) {
         /* currently, there is nothing to do here */
         \Mergy\TextUI\Output::error($oException->getMessage());
     }
     unset($oAggregate);
     return $this;
 }
예제 #4
0
파일: Command.php 프로젝트: hpbuniat/mergy
 /**
  * Handle passed arguments
  *
  * @param array $argv
  *
  * @return Command
  *
  * @TODO Cleanup!
  */
 public function handleArguments(array $argv = array())
 {
     try {
         $this->_aArguments = \Mergy\TextUI\Parameter::parse($argv, $this);
     } catch (\Mergy\TextUI\Parameter\Exception $oException) {
         return false;
     }
     if (defined('VERBOSE') === false) {
         define('VERBOSE', $this->_aArguments['verbose']);
     }
     $sConfig = self::CONFIG_FILE;
     if (isset($this->_aArguments['config']) === true) {
         $sConfig = $this->_aArguments['config'];
     }
     if (file_exists($sConfig) === true) {
         $this->_aArguments['config'] = json_decode(file_get_contents($sConfig));
     }
     if (empty($this->_aArguments['config']) === true) {
         \Mergy\TextUI\Output::error(self::CONFIG_ERROR);
         return false;
     }
     if ($this->_aArguments['config'] instanceof \stdClass !== true) {
         $this->_aArguments['config'] = new \stdClass();
     }
     if (empty($this->_aArguments['remote']) !== true and preg_match('!http(s)?://!i', $this->_aArguments['remote']) === 0) {
         if (isset($this->_aArguments['config']->remote) === true) {
             $aRemote = explode('/', $this->_aArguments['config']->remote);
             $aRemote[count($aRemote) - 1] = $this->_aArguments['remote'];
             $this->_aArguments['remote'] = implode('/', $aRemote);
         }
     }
     foreach ($this->_aConfig as $sArg => $sConfig) {
         if (empty($this->_aArguments[$sArg]) !== true) {
             $this->_aArguments['config']->{$sConfig} = $this->_aArguments[$sArg];
             unset($this->_aArguments[$sArg]);
         } elseif (isset($this->_aArguments['config']->{$sConfig}) === false) {
             $this->_aArguments['config']->{$sConfig} = null;
         }
     }
     $this->_aArguments['config']->tickets = explode(',', $this->_aArguments['config']->tickets);
     $this->_aArguments['config']->force = explode(',', $this->_aArguments['config']->force);
     if ($this->_aArguments['strict'] === true) {
         $this->_aArguments['config']->force = false;
     }
     if (empty($this->_aArguments['config']->notifiers) === true) {
         $this->_aArguments['config']->notifiers = null;
     }
     if (empty($this->_aArguments['config']->parallel) === true) {
         $this->_aArguments['config']->parallel = null;
     }
     if (empty($this->_aArguments['config']->merge) === true) {
         $this->_aArguments['config']->merge = array('ticket', 'comment', 'revision');
     }
     try {
         $this->_oNotifier = \notifyy\Builder::build($this->_aArguments['config']->notifiers);
     } catch (\notifyy\Exception $oNotifyyException) {
         \Mergy\TextUI\Output::error($oNotifyyException->getMessage());
         return false;
     }
     if (defined('VERBOSE') === true and VERBOSE === true) {
         \Mergy\TextUI\Output::info(print_r($this->_aArguments, true));
     }
     $this->_oMergeTracker = new \Mergy\Util\Merge\Tracker($this->_aArguments['config']);
     $oAction = new \Mergy\Action($this->_aArguments['config'], $this->_oNotifier);
     if ($this->_aArguments['config']->continue !== true) {
         $oAction->setup()->init();
         $this->_oMergeTracker->clean();
     }
     try {
         $this->_aArguments = \Mergy\TextUI\Parameter::revisions($this->_aArguments, $oAction->command('Unmerged'));
     } catch (\Exception $oException) {
         \Mergy\TextUI\Output::error($oException->getMessage());
         return false;
     }
     $aTrackedTickets = $this->_oMergeTracker->get();
     sort($aTrackedTickets);
     $this->_aArguments['config']->tracked = $aTrackedTickets;
     unset($oAction);
     return $this;
 }
예제 #5
0
 /**
  * Parse the cli-arguments
  *
  * @param  array $aParameters
  * @param  \Mergy\TextUI\Command $oMergy
  *
  * @return array
  */
 public static function parse(array $aParameters = array(), \Mergy\TextUI\Command $oMergy)
 {
     try {
         $oOpts = new \GetOptionKit\GetOptionKit();
         $oOpts->add('c|config?', 'Set the config file');
         $oOpts->add('v|verbose', 'Toggle verbose mode');
         $oOpts->add('h|help', 'Show help');
         $oOpts->add('version', 'Show the version');
         $oOpts->add('r|rev?', 'Specific revision(s) to merge');
         $oOpts->add('t|ticket?', 'Specific ticket(s) to merge');
         $oOpts->add('force', 'Force merging');
         $oOpts->add('strict', 'No guessing, eg. !merge');
         $oOpts->add('remote?', 'Define the remote source');
         $oOpts->add('f|formatter?', 'The unmerged-rev listing formatter');
         $oOpts->add('p|path?', 'The merge-path (wc)');
         $oOpts->add('continue', 'Continue - do not revert wc');
         $oOpts->add('more', 'There is more coming, to not commit');
         $oOpts->add('commit', 'Commit after success');
         $oOpts->add('unattended', 'No questions');
         $oOpts->add('reintegrate', 'Use the reintegrate option');
         $oOpts->add('list', 'Show unmerged revisions as list');
         $oOpts->add('list-group', 'Group unmerged revisions by ticket');
         $oOpts->add('diff', 'Create a review diff');
         $oOpts->add('all', 'Use all unmerged revisions');
         $oOpts->add('diff-all', 'Equals --diff --all');
         try {
             $oResult = $oOpts->parse($aParameters);
         } catch (\Exception $oParseException) {
             \Mergy\TextUI\Output::error($oParseException->getMessage());
             return false;
         }
         if (empty($oResult->keys) !== true) {
             foreach ($oResult as $sOption => $mValue) {
                 switch ($sOption) {
                     case 'rev':
                         self::$_aArguments['cliRevisions'] = $mValue;
                         break;
                     case 'ticket':
                         self::$_aArguments['tickets'] = $mValue;
                         break;
                     case 'force':
                         self::$_aArguments['strict'] = false;
                         if (empty($option) !== true) {
                             self::$_aArguments['force-comment'] = $mValue;
                         }
                         break;
                     case 'strict':
                         self::$_aArguments['strict'] = true;
                         break;
                     case 'remote':
                         self::$_aArguments['remote'] = $mValue;
                         break;
                     case 'config':
                         self::$_aArguments['config'] = $mValue;
                         break;
                     case 'path':
                         self::$_aArguments['path'] = $mValue;
                         break;
                     case 'formatter':
                         self::$_aArguments['formatter'] = $mValue;
                         break;
                     case 'more':
                         self::$_aArguments['more'] = true;
                         break;
                     case 'continue':
                         self::$_aArguments['continue'] = true;
                         break;
                     case 'commit':
                         self::$_aArguments['continue'] = true;
                         self::$_aArguments['commit'] = true;
                         break;
                     case 'unattended':
                         self::$_aArguments['unattended'] = true;
                         break;
                     case 'reintegrate':
                         self::$_aArguments['reintegrate'] = true;
                         break;
                     case 'verbose':
                         self::$_aArguments['verbose'] = true;
                         break;
                     case 'list':
                         self::$_aArguments['list'] = true;
                         break;
                     case 'list-group':
                         self::$_aArguments['list'] = true;
                         self::$_aArguments['group'] = true;
                         break;
                     case 'diff':
                         self::$_aArguments['diff'] = true;
                         break;
                     case 'all':
                         self::$_aArguments['all'] = true;
                         break;
                     case 'diff-all':
                         self::$_aArguments['diff'] = true;
                         self::$_aArguments['all'] = true;
                         break;
                     case 'help':
                         $oMergy::showHelp();
                         throw new Parameter\Exception(Parameter\Exception::NO_PARSING);
                     case 'version':
                         $oMergy::printVersionString();
                         throw new Parameter\Exception(Parameter\Exception::NO_PARSING);
                     default:
                         throw new \InvalidArgumentException('Unknown option');
                         break;
                 }
             }
         } else {
             self::$_aArguments['all'] = true;
             self::$_aArguments['list'] = true;
             self::$_aArguments['group'] = true;
             self::$_aArguments['continue'] = true;
         }
     } catch (\InvalidArgumentException $e) {
         \Mergy\TextUI\Output::info($e->getMessage());
     }
     unset($oConsole);
     return self::$_aArguments;
 }