Ejemplo n.º 1
0
 /**
  * Update repository
  *
  * Update the repository to the most current state. Method will return
  * true, if an update happened, and false if no update was available.
  *
  * Optionally a version can be specified, in which case the repository
  * won't be updated to the latest version, but to the specified one.
  *
  * @param string $version
  * @return bool
  */
 public function update($version = null)
 {
     // Remember version before update try
     $oldVersion = $this->getVersionString();
     $process = new vcsSvnCliProcess();
     if ($version !== null) {
         $process->argument('-r' . $version);
     }
     $return = $process->argument('update')->argument(new pbsPathArgument($this->root))->execute();
     // Check if an update has happened
     $this->currentVersion = null;
     return $oldVersion !== $this->getVersionString();
 }
Ejemplo n.º 2
0
 /**
  * Get content for version
  *
  * Get the contents of the current resource in the specified version.
  *
  * @param string $version 
  * @return string
  */
 public function getVersionedContent($version)
 {
     if (!in_array($version, $this->getVersions(), true)) {
         throw new vcsNoSuchVersionException($this->path, $version);
     }
     if (($content = vcsCache::get($this->path, $version, 'content')) === false) {
         // Refetch the basic content information, and cache it.
         $process = new vcsSvnCliProcess();
         $process->argument('-r' . $version);
         // Execute command
         $return = $process->argument('cat')->argument(new pbsPathArgument($this->root . $this->path))->execute();
         vcsCache::cache($this->path, $version, 'content', $content = $process->stdoutOutput);
     }
     return $content;
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }