[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/query/filecontent/ -> DiffusionMercurialFileContentQuery.php (source)

   1  <?php
   2  
   3  final class DiffusionMercurialFileContentQuery
   4    extends DiffusionFileContentQuery {
   5  
   6    public function getFileContentFuture() {
   7      $drequest = $this->getRequest();
   8  
   9      $repository = $drequest->getRepository();
  10      $path = $drequest->getPath();
  11      $commit = $drequest->getCommit();
  12  
  13      if ($this->getNeedsBlame()) {
  14        // NOTE: We're using "--number" instead of "--changeset" because there is
  15        // no way to get "--changeset" to show us the full commit hashes.
  16        return $repository->getLocalCommandFuture(
  17          'annotate --user --number --rev %s -- %s',
  18          $commit,
  19          $path);
  20      } else {
  21        return $repository->getLocalCommandFuture(
  22          'cat --rev %s -- %s',
  23          $commit,
  24          $path);
  25      }
  26    }
  27  
  28    protected function executeQueryFromFuture(Future $future) {
  29      list($corpus) = $future->resolvex();
  30  
  31      $file_content = new DiffusionFileContent();
  32      $file_content->setCorpus($corpus);
  33  
  34      return $file_content;
  35    }
  36  
  37    protected function tokenizeLine($line) {
  38      $matches = null;
  39  
  40      preg_match(
  41        '/^(.*?)\s+([0-9]+): (.*)$/',
  42        $line,
  43        $matches);
  44  
  45      return array($matches[2], $matches[1], $matches[3]);
  46    }
  47  
  48    /**
  49     * Convert local revision IDs into full commit identifier hashes.
  50     */
  51    protected function processRevList(array $rev_list) {
  52      $drequest = $this->getRequest();
  53      $repository = $drequest->getRepository();
  54  
  55      $revs = array_unique($rev_list);
  56      foreach ($revs as $key => $rev) {
  57        $revs[$key] = '--rev '.(int)$rev;
  58      }
  59  
  60      list($stdout) = $repository->execxLocalCommand(
  61        'log --template=%s %C',
  62        '{rev} {node}\\n',
  63        implode(' ', $revs));
  64  
  65      $map = array();
  66      foreach (explode("\n", trim($stdout)) as $line) {
  67        list($rev, $node) = explode(' ', $line);
  68        $map[$rev] = $node;
  69      }
  70  
  71      foreach ($rev_list as $k => $rev) {
  72        $rev_list[$k] = $map[$rev];
  73      }
  74  
  75      return $rev_list;
  76    }
  77  
  78  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1