Use CustomField, not AuxiliaryField, to power RevisionView
Summary: Ref T2222. This will probably have some rough edges for a bit (e.g., weird cases I didn't remember or think of), but there's no change to the underlying data and we can easily revert if things get too messy. Test Plan: Looked at a variety of revisions and saw sensible output. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8361
This commit is contained in:
@@ -41,6 +41,8 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
"This revision has no diffs. Something has gone quite wrong.");
|
||||
}
|
||||
|
||||
$revision->attachActiveDiff(last($diffs));
|
||||
|
||||
$diff_vs = $request->getInt('vs');
|
||||
|
||||
$target_id = $request->getInt('id');
|
||||
@@ -82,8 +84,6 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
$target_manual->getID());
|
||||
$props = mpull($props, 'getData', 'getName');
|
||||
|
||||
$aux_fields = $this->loadAuxiliaryFields($revision);
|
||||
|
||||
$comments = $revision->loadComments();
|
||||
|
||||
$all_changesets = $changesets;
|
||||
@@ -113,25 +113,8 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
}
|
||||
}
|
||||
|
||||
$aux_phids = array();
|
||||
foreach ($aux_fields as $key => $aux_field) {
|
||||
$aux_field->setDiff($target);
|
||||
$aux_field->setManualDiff($target_manual);
|
||||
$aux_field->setDiffProperties($props);
|
||||
$aux_phids[$key] = $aux_field->getRequiredHandlePHIDsForRevisionView();
|
||||
}
|
||||
$object_phids = array_merge($object_phids, array_mergev($aux_phids));
|
||||
$object_phids = array_unique($object_phids);
|
||||
|
||||
$handles = $this->loadViewerHandles($object_phids);
|
||||
|
||||
foreach ($aux_fields as $key => $aux_field) {
|
||||
// Make sure each field only has access to handles it specifically
|
||||
// requested, not all handles. Otherwise you can get a field which works
|
||||
// only in the presence of other fields.
|
||||
$aux_field->setHandles(array_select_keys($handles, $aux_phids[$key]));
|
||||
}
|
||||
|
||||
$request_uri = $request->getRequestURI();
|
||||
|
||||
$limit = 100;
|
||||
@@ -184,32 +167,22 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
$visible_changesets = $changesets;
|
||||
}
|
||||
|
||||
$field_list = PhabricatorCustomField::getObjectFields(
|
||||
$revision,
|
||||
PhabricatorCustomField::ROLE_VIEW);
|
||||
|
||||
$field_list->setViewer($user);
|
||||
$field_list->readFieldsFromStorage($revision);
|
||||
|
||||
$revision_detail = id(new DifferentialRevisionDetailView())
|
||||
->setUser($user)
|
||||
->setRevision($revision)
|
||||
->setDiff(end($diffs))
|
||||
->setAuxiliaryFields($aux_fields)
|
||||
->setCustomFields($field_list)
|
||||
->setURI($request->getRequestURI());
|
||||
|
||||
$actions = $this->getRevisionActions($revision);
|
||||
|
||||
$custom_renderer_class = PhabricatorEnv::getEnvConfig(
|
||||
'differential.revision-custom-detail-renderer');
|
||||
if ($custom_renderer_class) {
|
||||
|
||||
// TODO: build a better version of the action links and deprecate the
|
||||
// whole DifferentialRevisionDetailRenderer class.
|
||||
$custom_renderer = newv($custom_renderer_class, array());
|
||||
$custom_renderer->setUser($user);
|
||||
$custom_renderer->setDiff($target);
|
||||
if ($diff_vs) {
|
||||
$custom_renderer->setVSDiff($diffs[$diff_vs]);
|
||||
}
|
||||
$actions = array_merge(
|
||||
$actions,
|
||||
$custom_renderer->generateActionLinks($revision, $target_manual));
|
||||
}
|
||||
|
||||
$whitespace = $request->getStr(
|
||||
'whitespace',
|
||||
DifferentialChangesetParser::WHITESPACE_IGNORE_ALL);
|
||||
@@ -340,7 +313,9 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
|
||||
$comment_form = new DifferentialAddCommentView();
|
||||
$comment_form->setRevision($revision);
|
||||
$comment_form->setAuxFields($aux_fields);
|
||||
|
||||
// TODO: Restore the ability for fields to add accept warnings.
|
||||
|
||||
$comment_form->setActions($this->getRevisionCommentActions($revision));
|
||||
|
||||
$action_uri = '/differential/comment/save/';
|
||||
@@ -450,46 +425,42 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
$revision,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$links = array();
|
||||
$actions = array();
|
||||
|
||||
$links[] = array(
|
||||
'icon' => 'edit',
|
||||
'href' => "/differential/revision/edit/{$revision_id}/",
|
||||
'name' => pht('Edit Revision'),
|
||||
'disabled' => !$can_edit,
|
||||
'sigil' => $can_edit ? null : 'workflow',
|
||||
);
|
||||
$actions[] = id(new PhabricatorActionView())
|
||||
->setIcon('edit')
|
||||
->setHref("/differential/revision/edit/{$revision_id}/")
|
||||
->setName(pht('Edit Revision'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit);
|
||||
|
||||
$this->requireResource('phabricator-object-selector-css');
|
||||
$this->requireResource('javelin-behavior-phabricator-object-selector');
|
||||
|
||||
$links[] = array(
|
||||
'icon' => 'link',
|
||||
'name' => pht('Edit Dependencies'),
|
||||
'href' => "/search/attach/{$revision_phid}/DREV/dependencies/",
|
||||
'sigil' => 'workflow',
|
||||
'disabled' => !$can_edit,
|
||||
);
|
||||
$actions[] = id(new PhabricatorActionView())
|
||||
->setIcon('link')
|
||||
->setName(pht('Edit Dependencies'))
|
||||
->setHref("/search/attach/{$revision_phid}/DREV/dependencies/")
|
||||
->setWorkflow(true)
|
||||
->setDisabled(!$can_edit);
|
||||
|
||||
$maniphest = 'PhabricatorApplicationManiphest';
|
||||
if (PhabricatorApplication::isClassInstalled($maniphest)) {
|
||||
$links[] = array(
|
||||
'icon' => 'attach',
|
||||
'name' => pht('Edit Maniphest Tasks'),
|
||||
'href' => "/search/attach/{$revision_phid}/TASK/",
|
||||
'sigil' => 'workflow',
|
||||
'disabled' => !$can_edit,
|
||||
);
|
||||
$actions[] = id(new PhabricatorActionView())
|
||||
->setIcon('attach')
|
||||
->setName(pht('Edit Maniphest Tasks'))
|
||||
->setHref("/search/attach/{$revision_phid}/TASK/")
|
||||
->setWorkflow(true)
|
||||
->setDisabled(!$can_edit);
|
||||
}
|
||||
|
||||
$request_uri = $this->getRequest()->getRequestURI();
|
||||
$links[] = array(
|
||||
'icon' => 'download',
|
||||
'name' => pht('Download Raw Diff'),
|
||||
'href' => $request_uri->alter('download', 'true')
|
||||
);
|
||||
$actions[] = id(new PhabricatorActionView())
|
||||
->setIcon('download')
|
||||
->setName(pht('Download Raw Diff'))
|
||||
->setHref($request_uri->alter('download', 'true'));
|
||||
|
||||
return $links;
|
||||
return $actions;
|
||||
}
|
||||
|
||||
private function getRevisionCommentActions(DifferentialRevision $revision) {
|
||||
@@ -689,25 +660,6 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||
return array($changesets, $vs_map, $vs_changesets, $refs);
|
||||
}
|
||||
|
||||
private function loadAuxiliaryFields(DifferentialRevision $revision) {
|
||||
|
||||
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||
->getFieldSpecifications();
|
||||
foreach ($aux_fields as $key => $aux_field) {
|
||||
if (!$aux_field->shouldAppearOnRevisionView()) {
|
||||
unset($aux_fields[$key]);
|
||||
} else {
|
||||
$aux_field->setUser($this->getRequest()->getUser());
|
||||
}
|
||||
}
|
||||
|
||||
$aux_fields = DifferentialAuxiliaryField::loadFromStorage(
|
||||
$revision,
|
||||
$aux_fields);
|
||||
|
||||
return $aux_fields;
|
||||
}
|
||||
|
||||
private function buildSymbolIndexes(
|
||||
PhabricatorRepositoryArcanistProject $arc_project,
|
||||
array $visible_changesets) {
|
||||
|
||||
Reference in New Issue
Block a user