2012-05-02 13:43:45 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
final class DiffusionMercurialRawDiffQuery extends DiffusionRawDiffQuery {
|
|
|
|
|
|
2016-08-26 09:37:53 -07:00
|
|
|
protected function newQueryFuture() {
|
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.
|
2017-11-09 07:23:40 -08:00
|
|
|
$against = hgsprintf('(%s^ or null)', $commit);
|
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,
|
2017-11-09 07:23:40 -08:00
|
|
|
hgsprintf('%s', $commit),
|
2012-05-02 13:43:45 -07:00
|
|
|
$path);
|
|
|
|
|
|
2016-08-26 09:37:53 -07:00
|
|
|
return $future;
|
2012-05-02 13:43:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|