2012-05-02 13:43:45 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
final class DiffusionMercurialRawDiffQuery extends DiffusionRawDiffQuery {
|
|
|
|
|
|
|
|
|
|
protected function executeQuery() {
|
2013-12-09 09:20:40 -08:00
|
|
|
return $this->executeRawDiffCommand();
|
2012-10-08 16:35:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function executeRawDiffCommand() {
|
2012-05-02 13:43:45 -07:00
|
|
|
$drequest = $this->getRequest();
|
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
|
2014-05-13 13:53:06 -07:00
|
|
|
$commit = $this->getAnchorCommit();
|
2012-05-02 13:43:45 -07:00
|
|
|
|
|
|
|
|
// If there's no path, get the entire raw diff.
|
|
|
|
|
$path = nonempty($drequest->getPath(), '.');
|
|
|
|
|
|
2012-07-26 15:00:24 -07:00
|
|
|
$against = $this->getAgainstCommit();
|
|
|
|
|
if ($against === null) {
|
2013-12-09 09:20:40 -08:00
|
|
|
// If `$commit` has no parents (usually because it's the first commit
|
|
|
|
|
// in the repository), we want to diff against `null`. This revset will
|
|
|
|
|
// do that for us automatically.
|
|
|
|
|
$against = '('.$commit.'^ or null)';
|
2012-07-26 15:00:24 -07:00
|
|
|
}
|
|
|
|
|
|
2012-05-02 13:43:45 -07:00
|
|
|
$future = $repository->getLocalCommandFuture(
|
2013-12-09 09:20:40 -08:00
|
|
|
'diff -U %d --git --rev %s --rev %s -- %s',
|
2012-05-02 13:43:45 -07:00
|
|
|
$this->getLinesOfContext(),
|
2012-07-26 15:00:24 -07:00
|
|
|
$against,
|
2012-05-02 13:43:45 -07:00
|
|
|
$commit,
|
|
|
|
|
$path);
|
|
|
|
|
|
2014-01-03 12:27:19 -08:00
|
|
|
$this->configureFuture($future);
|
2012-05-02 13:43:45 -07:00
|
|
|
|
|
|
|
|
list($raw_diff) = $future->resolvex();
|
|
|
|
|
|
|
|
|
|
return $raw_diff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|