mirror of
https://we.phorge.it/source/phorge.git
synced 2025-04-07 18:08:31 +02:00
Fix the exception when watching the first commit of a mercurial repo
Summary: Most checks were actually in place, but `ExecFuture` throws a `CommandException` which wasn't taken into account. Test Plan: look at the first command and no longer saw an exception. Also, other commits worked as well. Reviewers: richardvanvelzen Reviewed By: richardvanvelzen CC: krisbuist, Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7730
This commit is contained in:
parent
0ed281d25e
commit
5d27aeb240
1 changed files with 6 additions and 19 deletions
|
@ -3,23 +3,7 @@
|
||||||
final class DiffusionMercurialRawDiffQuery extends DiffusionRawDiffQuery {
|
final class DiffusionMercurialRawDiffQuery extends DiffusionRawDiffQuery {
|
||||||
|
|
||||||
protected function executeQuery() {
|
protected function executeQuery() {
|
||||||
$raw_diff = $this->executeRawDiffCommand();
|
return $this->executeRawDiffCommand();
|
||||||
|
|
||||||
// the only legitimate case here is if we are looking at the first commit
|
|
||||||
// in the repository. no parents means first commit.
|
|
||||||
if (!$raw_diff) {
|
|
||||||
$drequest = $this->getRequest();
|
|
||||||
$parent_query =
|
|
||||||
DiffusionCommitParentsQuery::newFromDiffusionRequest($drequest);
|
|
||||||
$parents = $parent_query->loadParents();
|
|
||||||
if ($parents === array()) {
|
|
||||||
// mercurial likes the string null here
|
|
||||||
$this->setAgainstCommit('null');
|
|
||||||
$raw_diff = $this->executeRawDiffCommand();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $raw_diff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,11 +18,14 @@ final class DiffusionMercurialRawDiffQuery extends DiffusionRawDiffQuery {
|
||||||
|
|
||||||
$against = $this->getAgainstCommit();
|
$against = $this->getAgainstCommit();
|
||||||
if ($against === null) {
|
if ($against === null) {
|
||||||
$against = $commit.'^';
|
// 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)';
|
||||||
}
|
}
|
||||||
|
|
||||||
$future = $repository->getLocalCommandFuture(
|
$future = $repository->getLocalCommandFuture(
|
||||||
'diff -U %d --git --rev %s:%s -- %s',
|
'diff -U %d --git --rev %s --rev %s -- %s',
|
||||||
$this->getLinesOfContext(),
|
$this->getLinesOfContext(),
|
||||||
$against,
|
$against,
|
||||||
$commit,
|
$commit,
|
||||||
|
|
Loading…
Add table
Reference in a new issue