Example #1
0
 function doCvsDiff($command, $options, $params)
 {
     $this->output = '';
     if (sizeof($params) < 1) {
         $help = $this->getHelp($command);
         return $this->raiseError("{$command}: missing parameter: {$help['0']}");
     }
     $obj = new PEAR_Common();
     $info = $obj->infoFromDescriptionFile($params[0]);
     if (PEAR::isError($info)) {
         return $this->raiseError($info);
     }
     $files = array_keys($info['filelist']);
     $cmd = "cvs";
     if (isset($options['quiet'])) {
         $cmd .= ' -q';
         unset($options['quiet']);
     }
     if (isset($options['reallyquiet'])) {
         $cmd .= ' -Q';
         unset($options['reallyquiet']);
     }
     if (isset($options['release'])) {
         $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $options['release']);
         $cvstag = "RELEASE_{$cvsversion}";
         $options['revision'] = $cvstag;
         unset($options['release']);
     }
     $execute = true;
     if (isset($options['dry-run'])) {
         $execute = false;
         unset($options['dry-run']);
     }
     $cmd .= ' diff';
     // the rest of the options are passed right on to "cvs diff"
     foreach ($options as $option => $optarg) {
         $arg = @$this->commands[$command]['options'][$option]['arg'];
         $short = @$this->commands[$command]['options'][$option]['shortopt'];
         $cmd .= $short ? " -{$short}" : " --{$option}";
         if ($arg && $optarg) {
             $cmd .= ($short ? '' : '=') . escapeshellarg($optarg);
         }
     }
     foreach ($files as $file) {
         $cmd .= ' ' . escapeshellarg($file);
     }
     if ($this->config->get('verbose') > 1) {
         $this->output .= "+ {$cmd}\n";
     }
     if ($execute) {
         $fp = popen($cmd, "r");
         while ($line = fgets($fp, 1024)) {
             $this->output .= rtrim($line) . "\n";
         }
         pclose($fp);
     }
     $this->ui->outputData($this->output, $command);
     return true;
 }