Exemplo n.º 1
0
 /**
  * Get resource log
  *
  * Get the full log for the current resource up tu the current revision
  *
  * @return arbitXml
  */
 protected function getResourceLog()
 {
     if (($log = vcsCache::get($this->path, $this->currentVersion, 'log')) === false) {
         // Refetch the basic logrmation, and cache it.
         $process = new vcsSvnCliProcess();
         $process->argument('--xml');
         // Fecth for specified version, if set
         if ($this->currentVersion !== null) {
             $process->argument('-r0:' . $this->currentVersion);
         }
         // Execute logr command
         $return = $process->argument('log')->argument(new pbsPathArgument($this->root . $this->path))->execute();
         // Transform XML into object array
         $xmlLog = arbitXml::loadString($process->stdoutOutput);
         $log = array();
         foreach ($xmlLog->logentry as $entry) {
             $log[(string) $entry['revision']] = new vcsLogEntry($entry['revision'], $entry->author, $entry->msg, strtotime($entry->date));
         }
         uksort($log, array($this, 'compareVersions'));
         $last = end($log);
         // Cache extracted data
         vcsCache::cache($this->path, $this->currentVersion = (string) $last->version, 'log', $log);
     }
     return $log;
 }
Exemplo n.º 2
0
 /**
  * Get blame information for resource
  *
  * The method should return author and revision information for each line,
  * describing who when last changed the current resource. The returned
  * array should look like:
  * <code>
  *  array(
  *      T_LINE_NUMBER => array(
  *          'author'  => T_STRING,
  *          'version' => T_STRING,
  *      ),
  *      ...
  *  );
  * </code>
  *
  * If some file in the repository has no blame information associated, like
  * binary files, the method should return false.
  *
  * Optionally a version may be specified which defines a later version of
  * the resource for which the blame information should be returned.
  *
  * @param mixed $version
  * @return mixed
  */
 public function blame($version = null)
 {
     $version = $version === null ? $this->getVersionString() : $version;
     if (!in_array($version, $this->getVersions(), true)) {
         throw new vcsNoSuchVersionException($this->path, $version);
     }
     if (($blame = vcsCache::get($this->path, $version, 'blame')) === false) {
         // Refetch the basic blamermation, and cache it.
         $process = new vcsSvnCliProcess();
         $process->argument('--xml');
         // Execute command
         $return = $process->argument('blame')->argument(new pbsPathArgument($this->root . $this->path))->execute();
         $xml = arbitXml::loadString($process->stdoutOutput);
         // Check if blame information si available. Is absent fro binary
         // files.
         if (!$xml->target) {
             return false;
         }
         $blame = array();
         $contents = preg_split('(\\r\\n|\\r|\\n)', $this->getVersionedContent($version));
         foreach ($xml->target[0]->entry as $nr => $entry) {
             $blame[] = new vcsBlameStruct($contents[$nr], $entry->commit[0]['revision'], $entry->commit[0]->author, strtotime($entry->commit[0]->date));
         }
         vcsCache::cache($this->path, $version, 'blame', $blame);
     }
     return $blame;
 }