[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/query/rawdiff/ -> DiffusionGitRawDiffQuery.php (source)

   1  <?php
   2  
   3  final class DiffusionGitRawDiffQuery extends DiffusionRawDiffQuery {
   4  
   5    protected function executeQuery() {
   6      $drequest = $this->getRequest();
   7      $repository = $drequest->getRepository();
   8  
   9      $commit = $this->getAnchorCommit();
  10  
  11      $options = array(
  12        '-M',
  13        '-C',
  14        '--no-ext-diff',
  15        '--no-color',
  16        '--src-prefix=a/',
  17        '--dst-prefix=b/',
  18        '-U'.(int)$this->getLinesOfContext(),
  19      );
  20      $options = implode(' ', $options);
  21  
  22      $against = $this->getAgainstCommit();
  23      if ($against === null) {
  24        $against = $commit.'^';
  25      }
  26  
  27      // If there's no path, get the entire raw diff.
  28      $path = nonempty($drequest->getPath(), '.');
  29  
  30      $future = $repository->getLocalCommandFuture(
  31        'diff %C %s %s -- %s',
  32        $options,
  33        $against,
  34        $commit,
  35        $path);
  36  
  37      $this->configureFuture($future);
  38  
  39      try {
  40        list($raw_diff) = $future->resolvex();
  41      } catch (CommandException $ex) {
  42        // Check if this is the root commit by seeing if it has parents.
  43        list($parents) = $repository->execxLocalCommand(
  44          'log --format=%s %s --',
  45          '%P', // "parents"
  46          $commit);
  47  
  48        if (strlen(trim($parents))) {
  49          throw $ex;
  50        }
  51  
  52        // No parents means we're looking at the root revision. Diff against
  53        // the empty tree hash instead, since there is no parent so "^" does
  54        // not work. See ArcanistGitAPI for more discussion.
  55        $future = $repository->getLocalCommandFuture(
  56          'diff %C %s %s -- %s',
  57          $options,
  58          ArcanistGitAPI::GIT_MAGIC_ROOT_COMMIT,
  59          $commit,
  60          $drequest->getPath());
  61  
  62        $this->configureFuture($future);
  63  
  64        list($raw_diff) = $future->resolvex();
  65      }
  66  
  67      return $raw_diff;
  68    }
  69  
  70  }


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