コード例 #1
0
ファイル: Diff.php プロジェクト: hpbuniat/mergy
 /**
  * (non-PHPdoc)
  * @see \Mergy\Util\Cacheable::_get()
  */
 protected function _get()
 {
     $bDiff = true;
     switch ($this->_sType) {
         case 'deleted':
             $bDiff = false;
             break;
         case 'added':
             $sSwitch = '@' . $this->_iRevision;
             $sCommand = 'cat';
             break;
         default:
             $sSwitch = '@' . $this->_iRevision . ' -c ' . $this->_iRevision;
             $sCommand = 'diff';
             break;
     }
     if ($bDiff === true) {
         $sCommand = 'svn ' . $sCommand . ' "' . $this->_sPath . '"' . $sSwitch;
         $this->_oCommand->command($sCommand)->execute();
         $this->_mCache = $this->_oCommand->get();
         if ($this->_oCommand->isSuccess() !== true) {
             $this->_mCache = '';
             \Mergy\TextUI\Output::info(sprintf(self::ERROR, $sCommand));
         }
     }
     return $this;
 }
コード例 #2
0
ファイル: Files.php プロジェクト: hpbuniat/mergy
 /**
  * (non-PHPdoc)
  * @see \Mergy\Util\Cacheable::_get()
  */
 protected function _get()
 {
     $sCommand = 'svn diff ' . $this->_sRepository . ' --xml --summarize -c ' . $this->_iRevision;
     $this->_oCommand->command($sCommand)->execute();
     $this->_mCache = $this->_oCommand->get();
     if ($this->_oCommand->isSuccess() !== true) {
         $this->_mCache = '';
         \Mergy\TextUI\Output::info(sprintf(self::ERROR, $sCommand));
     }
     return $this;
 }
コード例 #3
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;
 }
コード例 #4
0
ファイル: Unmerged.php プロジェクト: hpbuniat/mergy
 /**
  * (non-PHPdoc)
  * @see AbstractAction::_execute()
  */
 protected function _execute()
 {
     $this->_oCommand->execute('svn mergeinfo --show-revs eligible ' . $this->_oConfig->remote . ' ' . $this->_oConfig->path);
     if ($this->_oCommand->isSuccess() !== true) {
         $this->_bSuccess = false;
     }
     if (defined('VERBOSE') === true and VERBOSE === true or $this->_bSuccess === false) {
         \Mergy\TextUI\Output::info(implode(',', explode(PHP_EOL, trim($this->_oCommand->get()))));
     }
     return true;
 }
コード例 #5
0
ファイル: Phpunit.php プロジェクト: hpbuniat/mergy
 /**
  * (non-PHPdoc)
  * @see AbstractAction::_execute()
  */
 protected function _execute()
 {
     $this->_oCommand->execute('cd ' . $this->_oConfig->path . ';' . $this->_oProperties->command);
     $this->_bSuccess = true;
     if ($this->_oCommand->isSuccess() !== true) {
         $this->_bSuccess = false;
     }
     if (defined('VERBOSE') === true and VERBOSE === true or $this->_bSuccess === false) {
         \Mergy\TextUI\Output::info($this->_oCommand->get());
     }
     return true;
 }
コード例 #6
0
ファイル: Commit.php プロジェクト: hpbuniat/mergy
 /**
  * (non-PHPdoc)
  * @see AbstractAction::_execute()
  */
 protected function _execute()
 {
     if (($this->_oConfig->unattended !== true or $this->_oConfig->commit === true) and $this->_oConfig->more !== true) {
         $sMessage = sprintf('-- merged with %s', $this->_oConfig->remote) . PHP_EOL . sprintf('-- by %s (%s)', \Mergy\TextUI\Command::NAME, \Mergy\TextUI\Command::URL) . PHP_EOL . PHP_EOL;
         if (empty($this->_oConfig->tracked) !== true) {
             foreach ($this->_oConfig->tracked as $sTicket) {
                 $sMessage .= '-- ' . $this->_oConfig->issues . $sTicket . PHP_EOL;
             }
         }
         $this->_oCommand->execute('svn ci ' . $this->_oConfig->path . ' --message "' . $sMessage . '"');
         $this->_bSuccess = true;
         if ($this->_oCommand->isSuccess() !== true) {
             $this->_bSuccess = false;
         }
         if (defined('VERBOSE') === true and VERBOSE === true or $this->_bSuccess === false) {
             \Mergy\TextUI\Output::info($this->_oCommand->get());
         }
         return true;
     }
     return false;
 }
コード例 #7
0
ファイル: Revert.php プロジェクト: hpbuniat/mergy
 /**
  * (non-PHPdoc)
  * @see AbstractAction::_execute()
  */
 protected function _execute()
 {
     $this->_oCommand->execute('svn revert --non-interactive -R -q ' . $this->_oConfig->path);
     if ($this->_oCommand->isSuccess() !== true) {
         $this->_bSuccess = false;
     }
     if ($this->_bSuccess === true) {
         $this->_oCommand->execute('svn status --no-ignore ' . $this->_oConfig->path . ' | grep -e ^\\? -e ^I | awk \'{print $2}\'| xargs -r rm -r');
         if ($this->_oCommand->isSuccess() !== true) {
             $this->_bSuccess = false;
         }
     }
     if ($this->_bSuccess === true) {
         $this->_oCommand->execute('svn up --non-interactive --ignore-externals --accept tf ' . $this->_oConfig->path);
         if ($this->_oCommand->isSuccess() !== true) {
             $this->_bSuccess = false;
         }
     }
     if (defined('VERBOSE') === true and VERBOSE === true or $this->_bSuccess === false) {
         \Mergy\TextUI\Output::info($this->_oCommand->get());
     }
     return true;
 }
コード例 #8
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;
 }
コード例 #9
0
ファイル: AbstractAction.php プロジェクト: hpbuniat/mergy
 /**
  * Confirm the result of an action
  *
  * @param  array $aExpected The expected input - needs keys continue & abort
  *
  * @return AbstractAction
  */
 protected function _confirm(array $aExpected = array())
 {
     \Mergy\TextUI\Output::info('Press Enter to continue!');
     do {
         $rInput = fopen('php://stdin', 'r');
         $sInput = trim(fgets($rInput));
     } while (in_array($sInput, $aExpected) === false and empty($aExpected) !== true);
     if (isset($aExpected['abort']) === true and $sInput === $aExpected['abort']) {
         \Mergy\TextUI\Output::info('aborting ...');
         throw new \Exception($this::PROBLEM);
     }
     \Mergy\TextUI\Output::info('continuing ...');
     return $this;
 }
コード例 #10
0
ファイル: Command.php プロジェクト: hpbuniat/mergy
 /**
  * Execute a command and read the output
  *
  * @param  string $sCommand
  *
  * @return Command
  */
 public function execute($sCommand = null)
 {
     $this->command($sCommand);
     if (defined('VERBOSE') === true and VERBOSE === true) {
         \Mergy\TextUI\Output::info($this->_sCommand);
     }
     $rCommand = popen($this->_sCommand, 'r');
     $this->_sReturn = '';
     while (feof($rCommand) !== true) {
         $this->_sReturn .= fread($rCommand, 4096);
     }
     if (defined('VERBOSE') === true and VERBOSE === true) {
         \Mergy\TextUI\Output::info($this->_sReturn);
     }
     $this->_iStatus = pclose($rCommand);
     return $this;
 }
コード例 #11
0
ファイル: Command.php プロジェクト: hpbuniat/mergy
 /**
  * Print the version string
  *
  * @return void
  */
 public static function printVersionString()
 {
     \Mergy\TextUI\Output::info(self::VERSION);
 }
コード例 #12
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;
 }
コード例 #13
0
ファイル: Parameter.php プロジェクト: hpbuniat/mergy
 /**
  * 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;
 }
コード例 #14
0
ファイル: Merge.php プロジェクト: hpbuniat/mergy
 /**
  * (non-PHPdoc)
  * @see AbstractAction::_execute()
  */
 protected function _execute()
 {
     $sCommand = 'svn merge ' . $this->_oConfig->remote . ' --accept postpone --non-interactive ' . $this->_sRevision . ' ' . $this->_oConfig->path;
     if ($this->_oConfig->unattended !== true) {
         $sCommand .= ' | awk \'{a["A"]=32;a["U"]=34;a["C"]=31;a["M"]=34;a["G"]=37;a["?"]=33;a["D"]=36;printf("\\033[1;%sm%s\\033[0;00m\\n",a[$1],$0)}\'';
     }
     $this->_oCommand->execute($sCommand);
     $sResult = $this->_oCommand->get();
     // @FIXME: Better conflict check!
     if ($this->_oCommand->isSuccess() !== true or strpos($sResult, 'Summary of conflicts') !== false or strpos($sResult, 'Konfliktübersicht') !== false) {
         $this->_bSuccess = false;
     }
     if (defined('VERBOSE') === true and VERBOSE === true or $this->_bSuccess === false) {
         \Mergy\TextUI\Output::info($sResult);
     }
     return true;
 }
コード例 #15
0
ファイル: Handler.php プロジェクト: hpbuniat/mergy
 /**
  * Execute all actions of a stack
  *
  * @param  string $sMethod
  * @param  array $aArgs
  *
  * @return $this
  *
  * @throws \Mergy\Exception
  */
 public function __call($sMethod, $aArgs)
 {
     if (empty($this->_aStacks[$sMethod]) !== true) {
         foreach ($this->_aStacks[$sMethod] as $oProcess) {
             if (defined('VERBOSE') === true and VERBOSE === true) {
                 \Mergy\TextUI\Output::info('Executing ' . $oProcess->getName() . ' in ' . $sMethod);
             }
             $this->_aReturn[$oProcess->getName()] = $oProcess->execute()->get();
             if ($oProcess->isSuccess() !== true) {
                 throw new \Mergy\Exception($oProcess::PROBLEM);
             }
         }
     }
     return $this;
 }