Skip to content

Commit f6a13fd

Browse files
author
epriestley
committedFeb 27, 2014
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
1 parent 0b4a6b8 commit f6a13fd

13 files changed

+93
-237
lines changed
 

‎conf/default.conf.php

-2
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,6 @@
787787

788788
// -- Differential ---------------------------------------------------------- //
789789

790-
'differential.revision-custom-detail-renderer' => null,
791-
792790
// List of file regexps where whitespace is meaningful and should not
793791
// use 'ignore-all' by default
794792
'differential.whitespace-matters' => array(

‎src/applications/config/check/PhabricatorSetupCheckExtraConfig.php

+2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ public static function getAncientConfig() {
180180
'auth.sessions.web' => $session_reason,
181181
'tokenizer.ondemand' => pht(
182182
'Phabricator now manages typeahead strategies automatically.'),
183+
'differential.revision-custom-detail-renderer' => pht(
184+
'Obsolete; use standard rendering events instead.'),
183185
);
184186

185187
return $ancient_config;

‎src/applications/differential/config/PhabricatorDifferentialConfigOptions.php

-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ public function getDescription() {
1313

1414
public function getOptions() {
1515
return array(
16-
$this->newOption(
17-
'differential.revision-custom-detail-renderer',
18-
'class',
19-
null)
20-
->setBaseClass('DifferentialRevisionDetailRenderer')
21-
->setDescription(pht("Custom revision detail renderer.")),
2216
$this->newOption(
2317
'differential.whitespace-matters',
2418
'list<regex>',

‎src/applications/differential/controller/DifferentialRevisionDetailRenderer.php

-46
This file was deleted.

‎src/applications/differential/controller/DifferentialRevisionViewController.php

+37-85
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function processRequest() {
4141
"This revision has no diffs. Something has gone quite wrong.");
4242
}
4343

44+
$revision->attachActiveDiff(last($diffs));
45+
4446
$diff_vs = $request->getInt('vs');
4547

4648
$target_id = $request->getInt('id');
@@ -82,8 +84,6 @@ public function processRequest() {
8284
$target_manual->getID());
8385
$props = mpull($props, 'getData', 'getName');
8486

85-
$aux_fields = $this->loadAuxiliaryFields($revision);
86-
8787
$comments = $revision->loadComments();
8888

8989
$all_changesets = $changesets;
@@ -113,25 +113,8 @@ public function processRequest() {
113113
}
114114
}
115115

116-
$aux_phids = array();
117-
foreach ($aux_fields as $key => $aux_field) {
118-
$aux_field->setDiff($target);
119-
$aux_field->setManualDiff($target_manual);
120-
$aux_field->setDiffProperties($props);
121-
$aux_phids[$key] = $aux_field->getRequiredHandlePHIDsForRevisionView();
122-
}
123-
$object_phids = array_merge($object_phids, array_mergev($aux_phids));
124-
$object_phids = array_unique($object_phids);
125-
126116
$handles = $this->loadViewerHandles($object_phids);
127117

128-
foreach ($aux_fields as $key => $aux_field) {
129-
// Make sure each field only has access to handles it specifically
130-
// requested, not all handles. Otherwise you can get a field which works
131-
// only in the presence of other fields.
132-
$aux_field->setHandles(array_select_keys($handles, $aux_phids[$key]));
133-
}
134-
135118
$request_uri = $request->getRequestURI();
136119

137120
$limit = 100;
@@ -184,32 +167,22 @@ public function processRequest() {
184167
$visible_changesets = $changesets;
185168
}
186169

170+
$field_list = PhabricatorCustomField::getObjectFields(
171+
$revision,
172+
PhabricatorCustomField::ROLE_VIEW);
173+
174+
$field_list->setViewer($user);
175+
$field_list->readFieldsFromStorage($revision);
176+
187177
$revision_detail = id(new DifferentialRevisionDetailView())
188178
->setUser($user)
189179
->setRevision($revision)
190180
->setDiff(end($diffs))
191-
->setAuxiliaryFields($aux_fields)
181+
->setCustomFields($field_list)
192182
->setURI($request->getRequestURI());
193183

194184
$actions = $this->getRevisionActions($revision);
195185

196-
$custom_renderer_class = PhabricatorEnv::getEnvConfig(
197-
'differential.revision-custom-detail-renderer');
198-
if ($custom_renderer_class) {
199-
200-
// TODO: build a better version of the action links and deprecate the
201-
// whole DifferentialRevisionDetailRenderer class.
202-
$custom_renderer = newv($custom_renderer_class, array());
203-
$custom_renderer->setUser($user);
204-
$custom_renderer->setDiff($target);
205-
if ($diff_vs) {
206-
$custom_renderer->setVSDiff($diffs[$diff_vs]);
207-
}
208-
$actions = array_merge(
209-
$actions,
210-
$custom_renderer->generateActionLinks($revision, $target_manual));
211-
}
212-
213186
$whitespace = $request->getStr(
214187
'whitespace',
215188
DifferentialChangesetParser::WHITESPACE_IGNORE_ALL);
@@ -340,7 +313,9 @@ public function processRequest() {
340313

341314
$comment_form = new DifferentialAddCommentView();
342315
$comment_form->setRevision($revision);
343-
$comment_form->setAuxFields($aux_fields);
316+
317+
// TODO: Restore the ability for fields to add accept warnings.
318+
344319
$comment_form->setActions($this->getRevisionCommentActions($revision));
345320

346321
$action_uri = '/differential/comment/save/';
@@ -450,46 +425,42 @@ private function getRevisionActions(DifferentialRevision $revision) {
450425
$revision,
451426
PhabricatorPolicyCapability::CAN_EDIT);
452427

453-
$links = array();
428+
$actions = array();
454429

455-
$links[] = array(
456-
'icon' => 'edit',
457-
'href' => "/differential/revision/edit/{$revision_id}/",
458-
'name' => pht('Edit Revision'),
459-
'disabled' => !$can_edit,
460-
'sigil' => $can_edit ? null : 'workflow',
461-
);
430+
$actions[] = id(new PhabricatorActionView())
431+
->setIcon('edit')
432+
->setHref("/differential/revision/edit/{$revision_id}/")
433+
->setName(pht('Edit Revision'))
434+
->setDisabled(!$can_edit)
435+
->setWorkflow(!$can_edit);
462436

463437
$this->requireResource('phabricator-object-selector-css');
464438
$this->requireResource('javelin-behavior-phabricator-object-selector');
465439

466-
$links[] = array(
467-
'icon' => 'link',
468-
'name' => pht('Edit Dependencies'),
469-
'href' => "/search/attach/{$revision_phid}/DREV/dependencies/",
470-
'sigil' => 'workflow',
471-
'disabled' => !$can_edit,
472-
);
440+
$actions[] = id(new PhabricatorActionView())
441+
->setIcon('link')
442+
->setName(pht('Edit Dependencies'))
443+
->setHref("/search/attach/{$revision_phid}/DREV/dependencies/")
444+
->setWorkflow(true)
445+
->setDisabled(!$can_edit);
473446

474447
$maniphest = 'PhabricatorApplicationManiphest';
475448
if (PhabricatorApplication::isClassInstalled($maniphest)) {
476-
$links[] = array(
477-
'icon' => 'attach',
478-
'name' => pht('Edit Maniphest Tasks'),
479-
'href' => "/search/attach/{$revision_phid}/TASK/",
480-
'sigil' => 'workflow',
481-
'disabled' => !$can_edit,
482-
);
449+
$actions[] = id(new PhabricatorActionView())
450+
->setIcon('attach')
451+
->setName(pht('Edit Maniphest Tasks'))
452+
->setHref("/search/attach/{$revision_phid}/TASK/")
453+
->setWorkflow(true)
454+
->setDisabled(!$can_edit);
483455
}
484456

485457
$request_uri = $this->getRequest()->getRequestURI();
486-
$links[] = array(
487-
'icon' => 'download',
488-
'name' => pht('Download Raw Diff'),
489-
'href' => $request_uri->alter('download', 'true')
490-
);
458+
$actions[] = id(new PhabricatorActionView())
459+
->setIcon('download')
460+
->setName(pht('Download Raw Diff'))
461+
->setHref($request_uri->alter('download', 'true'));
491462

492-
return $links;
463+
return $actions;
493464
}
494465

495466
private function getRevisionCommentActions(DifferentialRevision $revision) {
@@ -689,25 +660,6 @@ private function loadChangesetsAndVsMap(
689660
return array($changesets, $vs_map, $vs_changesets, $refs);
690661
}
691662

692-
private function loadAuxiliaryFields(DifferentialRevision $revision) {
693-
694-
$aux_fields = DifferentialFieldSelector::newSelector()
695-
->getFieldSpecifications();
696-
foreach ($aux_fields as $key => $aux_field) {
697-
if (!$aux_field->shouldAppearOnRevisionView()) {
698-
unset($aux_fields[$key]);
699-
} else {
700-
$aux_field->setUser($this->getRequest()->getUser());
701-
}
702-
}
703-
704-
$aux_fields = DifferentialAuxiliaryField::loadFromStorage(
705-
$revision,
706-
$aux_fields);
707-
708-
return $aux_fields;
709-
}
710-
711663
private function buildSymbolIndexes(
712664
PhabricatorRepositoryArcanistProject $arc_project,
713665
array $visible_changesets) {

‎src/applications/differential/customfield/DifferentialBlameRevisionField.php

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public function getFieldDescription() {
1515
return pht('Stores a reference to what this fixes.');
1616
}
1717

18+
public function shouldDisableByDefault() {
19+
return true;
20+
}
21+
1822
public function shouldAppearInPropertyView() {
1923
return true;
2024
}

‎src/applications/differential/customfield/DifferentialHostField.php

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public function getFieldDescription() {
1515
return pht('Shows the local host where the diff came from.');
1616
}
1717

18+
public function shouldDisableByDefault() {
19+
return true;
20+
}
21+
1822
public function shouldAppearInPropertyView() {
1923
return true;
2024
}

‎src/applications/differential/customfield/DifferentialPathField.php

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public function getFieldDescription() {
1515
return pht('Shows the local path where the diff came from.');
1616
}
1717

18+
public function shouldDisableByDefault() {
19+
return true;
20+
}
21+
1822
public function shouldAppearInPropertyView() {
1923
return true;
2024
}

‎src/applications/differential/customfield/DifferentialRevertPlanField.php

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public function getFieldDescription() {
1515
return pht('Instructions for reverting/undoing this change.');
1616
}
1717

18+
public function shouldDisableByDefault() {
19+
return true;
20+
}
21+
1822
public function shouldAppearInPropertyView() {
1923
return true;
2024
}

‎src/applications/differential/storage/DifferentialRevision.php

+27-5
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,7 @@ public function isAutomaticallySubscribed($phid) {
469469
}
470470

471471
public function shouldShowSubscribersProperty() {
472-
// TODO: Differential does its own thing for now.
473-
return false;
472+
return true;
474473
}
475474

476475
public function shouldAllowSubscription($phid) {
@@ -483,19 +482,42 @@ public function shouldAllowSubscription($phid) {
483482

484483
public function getCustomFieldSpecificationForRole($role) {
485484
$fields = array(
485+
new DifferentialAuthorField(),
486+
486487
new DifferentialTitleField(),
487488
new DifferentialSummaryField(),
488489
new DifferentialTestPlanField(),
489490
new DifferentialReviewersField(),
491+
new DifferentialProjectReviewersField(),
490492
new DifferentialSubscribersField(),
491493
new DifferentialRepositoryField(),
492494
new DifferentialViewPolicyField(),
493495
new DifferentialEditPolicyField(),
496+
497+
new DifferentialDependsOnField(),
498+
new DifferentialDependenciesField(),
499+
new DifferentialManiphestTasksField(),
500+
new DifferentialCommitsField(),
501+
502+
new DifferentialJIRAIssuesField(),
503+
new DifferentialAsanaRepresentationField(),
504+
505+
new DifferentialBlameRevisionField(),
506+
new DifferentialPathField(),
507+
new DifferentialHostField(),
508+
new DifferentialRevertPlanField(),
509+
510+
new DifferentialApplyPatchField(),
494511
);
495512

496-
return array_fill_keys(
497-
mpull($fields, 'getFieldKey'),
498-
array('disabled' => false));
513+
$result = array();
514+
foreach ($fields as $field) {
515+
$result[$field->getFieldKey()] = array(
516+
'disabled' => $field->shouldDisableByDefault(),
517+
);
518+
}
519+
520+
return $result;
499521
}
500522

501523
public function getCustomFieldBaseClass() {

0 commit comments

Comments
 (0)
Failed to load comments.