/** * Get diff * * Get the diff between the current version and the given version. * Optionally you may specify another version then the current one as the * diff base as the second parameter. * * @param string $version * @param string $current * @return vcsResource */ public function getDiff($version, $current = null) { $current = $current === null ? $this->getVersionString() : $current; if (($diff = vcsCache::get($this->path, $version, 'diff')) !== false) { return $diff; } // Refetch the basic content information, and cache it. $process = new vcsCvsCliProcess(); // WTF: Why is there a non zero exit code? $process->nonZeroExitCodeException = false; // Configure process instance $process->workingDirectory($this->root)->redirect(vcsCvsCliProcess::STDERR, vcsCvsCliProcess::STDOUT)->argument('diff')->argument('-u')->argument('-r')->argument($version)->argument('-r')->argument($current)->argument('.' . $this->path)->execute(); $parser = new vcsUnifiedDiffParser(); $diff = $parser->parseString($process->stdoutOutput); vcsCache::cache($this->path, $version, 'diff', $diff); return $diff; }
/** * Get diff * * Get the diff between the current version and the given version. * Optionally you may specify another version then the current one as the * diff base as the second parameter. * * @param string $version * @param string $current * @return vcsResource */ public function getDiff($version, $current = null) { if (!in_array($version, $this->getVersions(), true)) { throw new vcsNoSuchVersionException($this->path, $version); } $diff = vcsCache::get($this->path, $version, 'diff'); if ($diff === false) { // Refetch the basic content information, and cache it. $process = new vcsHgCliProcess(); $process->workingDirectory($this->root); $process->argument('diff'); if ($current !== null) { $process->argument('-r' . $current); } $process->argument('-r' . $version); $process->argument(new pbsPathArgument('.' . $this->path)); $process->execute(); // Parse resulting unified diff $parser = new vcsUnifiedDiffParser(); $diff = $parser->parseString($process->stdoutOutput); vcsCache::cache($this->path, $version, 'diff', $diff); } return $diff; }
/** * Get diff * * Get the diff between the current version and the given version. * Optionally you may specify another version then the current one as the * diff base as the second parameter. * * @param string $version * @param string $current * @return vcsResource */ public function getDiff($version, $current = null) { $current = $current === null ? $this->getVersionString() : $current; if (($diff = vcsCache::get($this->path, $version, 'diff')) === false) { // Refetch the basic content information, and cache it. $process = new vcsSvnCliProcess(); $process->argument('-r' . $version . ':' . $current); // Execute command $return = $process->argument('diff')->argument(new pbsPathArgument($this->root . $this->path))->execute(); $parser = new vcsUnifiedDiffParser(); $diff = $parser->parseString($process->stdoutOutput); vcsCache::cache($this->path, $version, 'diff', $diff); } foreach ($diff as $fileDiff) { $fileDiff->from = substr($fileDiff->from, strlen($this->root)); $fileDiff->to = substr($fileDiff->to, strlen($this->root)); } return $diff; }