Skip to content

Commit 0b4a6b8

Browse files
author
epriestley
committedFeb 27, 2014
Add Branch and Arcanist Project CustomFields
Summary: Ref T2222. These are pretty straightforward. For these fields and a few others, the existing code shows the value for the "current/manual" diff (i.e., the diff selected in the diff selection table), not the "active" diff (i.e., the most recent diff attached to the revision). I'm going to drop that for now (always showing the most recent diff instead) and then reevaluate it once we're switched over. In 95% of cases these are the same, anyway. Test Plan: Looked at fields; this diff changes nothing on its own. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8359
1 parent 37b1b31 commit 0b4a6b8

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed
 

‎src/__phutil_library_map__.php

+6
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@
324324
'DifferentialAffectedPath' => 'applications/differential/storage/DifferentialAffectedPath.php',
325325
'DifferentialApplyPatchField' => 'applications/differential/customfield/DifferentialApplyPatchField.php',
326326
'DifferentialApplyPatchFieldSpecification' => 'applications/differential/field/specification/DifferentialApplyPatchFieldSpecification.php',
327+
'DifferentialArcanistProjectField' => 'applications/differential/customfield/DifferentialArcanistProjectField.php',
327328
'DifferentialArcanistProjectFieldSpecification' => 'applications/differential/field/specification/DifferentialArcanistProjectFieldSpecification.php',
328329
'DifferentialAsanaRepresentationField' => 'applications/differential/customfield/DifferentialAsanaRepresentationField.php',
329330
'DifferentialAsanaRepresentationFieldSpecification' => 'applications/differential/field/specification/DifferentialAsanaRepresentationFieldSpecification.php',
@@ -333,6 +334,7 @@
333334
'DifferentialAuxiliaryField' => 'applications/differential/storage/DifferentialAuxiliaryField.php',
334335
'DifferentialBlameRevisionField' => 'applications/differential/customfield/DifferentialBlameRevisionField.php',
335336
'DifferentialBlameRevisionFieldSpecification' => 'applications/differential/field/specification/DifferentialBlameRevisionFieldSpecification.php',
337+
'DifferentialBranchField' => 'applications/differential/customfield/DifferentialBranchField.php',
336338
'DifferentialBranchFieldSpecification' => 'applications/differential/field/specification/DifferentialBranchFieldSpecification.php',
337339
'DifferentialCCWelcomeMail' => 'applications/differential/mail/DifferentialCCWelcomeMail.php',
338340
'DifferentialCCsFieldSpecification' => 'applications/differential/field/specification/DifferentialCCsFieldSpecification.php',
@@ -462,6 +464,7 @@
462464
'DifferentialReviewersView' => 'applications/differential/view/DifferentialReviewersView.php',
463465
'DifferentialRevision' => 'applications/differential/storage/DifferentialRevision.php',
464466
'DifferentialRevisionControlSystem' => 'applications/differential/constants/DifferentialRevisionControlSystem.php',
467+
'DifferentialRevisionDetailRenderer' => 'applications/differential/controller/DifferentialRevisionDetailRenderer.php',
465468
'DifferentialRevisionDetailView' => 'applications/differential/view/DifferentialRevisionDetailView.php',
466469
'DifferentialRevisionEditController' => 'applications/differential/controller/DifferentialRevisionEditController.php',
467470
'DifferentialRevisionEditControllerPro' => 'applications/differential/controller/DifferentialRevisionEditControllerPro.php',
@@ -2504,6 +2507,7 @@
25042507
'ReleephDiffChurnFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffChurnFieldSpecification.php',
25052508
'ReleephDiffMessageFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffMessageFieldSpecification.php',
25062509
'ReleephDiffSizeFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffSizeFieldSpecification.php',
2510+
'ReleephDifferentialRevisionDetailRenderer' => 'applications/releeph/differential/ReleephDifferentialRevisionDetailRenderer.php',
25072511
'ReleephFieldParseException' => 'applications/releeph/field/exception/ReleephFieldParseException.php',
25082512
'ReleephFieldSelector' => 'applications/releeph/field/selector/ReleephFieldSelector.php',
25092513
'ReleephFieldSpecification' => 'applications/releeph/field/specification/ReleephFieldSpecification.php',
@@ -2890,6 +2894,7 @@
28902894
'DifferentialAffectedPath' => 'DifferentialDAO',
28912895
'DifferentialApplyPatchField' => 'DifferentialCustomField',
28922896
'DifferentialApplyPatchFieldSpecification' => 'DifferentialFieldSpecification',
2897+
'DifferentialArcanistProjectField' => 'DifferentialCustomField',
28932898
'DifferentialArcanistProjectFieldSpecification' => 'DifferentialFieldSpecification',
28942899
'DifferentialAsanaRepresentationField' => 'DifferentialCustomField',
28952900
'DifferentialAsanaRepresentationFieldSpecification' => 'DifferentialFieldSpecification',
@@ -2898,6 +2903,7 @@
28982903
'DifferentialAuthorFieldSpecification' => 'DifferentialFieldSpecification',
28992904
'DifferentialBlameRevisionField' => 'DifferentialStoredCustomField',
29002905
'DifferentialBlameRevisionFieldSpecification' => 'DifferentialFieldSpecification',
2906+
'DifferentialBranchField' => 'DifferentialCustomField',
29012907
'DifferentialBranchFieldSpecification' => 'DifferentialFieldSpecification',
29022908
'DifferentialCCWelcomeMail' => 'DifferentialReviewRequestMail',
29032909
'DifferentialCCsFieldSpecification' => 'DifferentialFieldSpecification',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
final class DifferentialArcanistProjectField
4+
extends DifferentialCustomField {
5+
6+
public function getFieldKey() {
7+
return 'differential:arcanist-project';
8+
}
9+
10+
public function getFieldName() {
11+
return pht('Arcanist Project');
12+
}
13+
14+
public function getFieldDescription() {
15+
return pht('Shows arcanist project name.');
16+
}
17+
18+
public function shouldAppearInPropertyView() {
19+
return true;
20+
}
21+
22+
public function renderPropertyViewLabel() {
23+
return $this->getFieldName();
24+
}
25+
26+
public function getRequiredHandlePHIDsForPropertyView() {
27+
$phid = $this->getArcanistProjectPHID();
28+
if ($phid) {
29+
return array($phid);
30+
}
31+
return array();
32+
}
33+
34+
public function renderPropertyViewValue(array $handles) {
35+
return $this->renderHandleList($handles);
36+
}
37+
38+
private function getArcanistProjectPHID() {
39+
return $this->getObject()->getActiveDiff()->getArcanistProjectPHID();
40+
}
41+
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
final class DifferentialBranchField
4+
extends DifferentialCustomField {
5+
6+
public function getFieldKey() {
7+
return 'differential:branch';
8+
}
9+
10+
public function getFieldName() {
11+
return pht('Branch');
12+
}
13+
14+
public function getFieldDescription() {
15+
return pht('Shows the branch a diff came from.');
16+
}
17+
18+
public function shouldAppearInPropertyView() {
19+
return true;
20+
}
21+
22+
public function renderPropertyViewLabel() {
23+
return $this->getFieldName();
24+
}
25+
26+
public function renderPropertyViewValue(array $handles) {
27+
return $this->getBranchDescription($this->getObject()->getActiveDiff());
28+
}
29+
30+
private function getBranchDescription(DifferentialDiff $diff) {
31+
$branch = $diff->getBranch();
32+
$bookmark = $diff->getBookmark();
33+
34+
if (strlen($branch) && strlen($bookmark)) {
35+
return pht('%s (bookmark) on %s (branch)', $bookmark, $branch);
36+
} else if (strlen($bookmark)) {
37+
return pht('%s (bookmark)', $bookmark);
38+
} else if (strlen($branch)) {
39+
return $branch;
40+
} else {
41+
return null;
42+
}
43+
}
44+
45+
}

0 commit comments

Comments
 (0)
Failed to load comments.