1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Fix differential.getdiff, etc., for diffs with no Arcanist Project

Summary:
`getArcanistProjectName()` has some logic which gets messy with the `self::ATTACHABLE` mechanism. This makes `differential.getdiff` and similar Conduit methods throw an exception when querying a diff which doesn't have a project. See <http://pastebin.com/Czzrd0Jz>.

Instead, unconditionally attach a project (possibly `null`) when loading diffs if they need projects.

Test Plan: Ran `differential.getdiff` against a `arc diff --raw` diff with no project, got a result instead of an exception.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, sttwister

Differential Revision: https://secure.phabricator.com/D7101
This commit is contained in:
epriestley 2013-09-24 10:48:40 -07:00
parent 0d77a7f39f
commit 119c2b8cec
2 changed files with 10 additions and 7 deletions

View file

@ -77,13 +77,16 @@ final class DifferentialDiffQuery
'phid IN (%Ls)', 'phid IN (%Ls)',
$phids); $phids);
$project_map = mpull($projects, null, 'getPHID'); $project_map = mpull($projects, null, 'getPHID');
foreach ($diffs as $diff) {
if ($diff->getArcanistProjectPHID()) {
$project = $project_map[$diff->getArcanistProjectPHID()];
$diff->attachArcanistProject($project);
}
}
} }
foreach ($diffs as $diff) {
$project = null;
if ($diff->getArcanistProjectPHID()) {
$project = idx($project_map, $diff->getArcanistProjectPHID());
}
$diff->attachArcanistProject($project);
}
return $diffs; return $diffs;
} }

View file

@ -62,7 +62,7 @@ final class DifferentialDiff
} }
public function attachArcanistProject( public function attachArcanistProject(
PhabricatorRepositoryArcanistProject $project) { PhabricatorRepositoryArcanistProject $project = null) {
$this->arcanistProject = $project; $this->arcanistProject = $project;
return $this; return $this;
} }