Page MenuHomePhabricator

D8357.id19865.diff
No OneTemporary

D8357.id19865.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -331,6 +331,7 @@
'DifferentialAuthorField' => 'applications/differential/customfield/DifferentialAuthorField.php',
'DifferentialAuthorFieldSpecification' => 'applications/differential/field/specification/DifferentialAuthorFieldSpecification.php',
'DifferentialAuxiliaryField' => 'applications/differential/storage/DifferentialAuxiliaryField.php',
+ 'DifferentialBlameRevisionField' => 'applications/differential/customfield/DifferentialBlameRevisionField.php',
'DifferentialBlameRevisionFieldSpecification' => 'applications/differential/field/specification/DifferentialBlameRevisionFieldSpecification.php',
'DifferentialBranchFieldSpecification' => 'applications/differential/field/specification/DifferentialBranchFieldSpecification.php',
'DifferentialCCWelcomeMail' => 'applications/differential/mail/DifferentialCCWelcomeMail.php',
@@ -404,6 +405,7 @@
'DifferentialFreeformFieldSpecification' => 'applications/differential/field/specification/DifferentialFreeformFieldSpecification.php',
'DifferentialGetWorkingCopy' => 'applications/differential/DifferentialGetWorkingCopy.php',
'DifferentialGitSVNIDFieldSpecification' => 'applications/differential/field/specification/DifferentialGitSVNIDFieldSpecification.php',
+ 'DifferentialHostField' => 'applications/differential/customfield/DifferentialHostField.php',
'DifferentialHostFieldSpecification' => 'applications/differential/field/specification/DifferentialHostFieldSpecification.php',
'DifferentialHovercardEventListener' => 'applications/differential/event/DifferentialHovercardEventListener.php',
'DifferentialHunk' => 'applications/differential/storage/DifferentialHunk.php',
@@ -436,6 +438,7 @@
'DifferentialPHIDTypeRevision' => 'applications/differential/phid/DifferentialPHIDTypeRevision.php',
'DifferentialParseCacheGarbageCollector' => 'applications/differential/garbagecollector/DifferentialParseCacheGarbageCollector.php',
'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php',
+ 'DifferentialPathField' => 'applications/differential/customfield/DifferentialPathField.php',
'DifferentialPathFieldSpecification' => 'applications/differential/field/specification/DifferentialPathFieldSpecification.php',
'DifferentialPrimaryPaneView' => 'applications/differential/view/DifferentialPrimaryPaneView.php',
'DifferentialProjectReviewersField' => 'applications/differential/customfield/DifferentialProjectReviewersField.php',
@@ -448,6 +451,7 @@
'DifferentialRepositoryFieldSpecification' => 'applications/differential/field/specification/DifferentialRepositoryFieldSpecification.php',
'DifferentialRepositoryLookup' => 'applications/differential/query/DifferentialRepositoryLookup.php',
'DifferentialResultsTableView' => 'applications/differential/view/DifferentialResultsTableView.php',
+ 'DifferentialRevertPlanField' => 'applications/differential/customfield/DifferentialRevertPlanField.php',
'DifferentialRevertPlanFieldSpecification' => 'applications/differential/field/specification/DifferentialRevertPlanFieldSpecification.php',
'DifferentialReviewRequestMail' => 'applications/differential/mail/DifferentialReviewRequestMail.php',
'DifferentialReviewedByFieldSpecification' => 'applications/differential/field/specification/DifferentialReviewedByFieldSpecification.php',
@@ -475,6 +479,7 @@
'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/DifferentialRevisionUpdateHistoryView.php',
'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php',
'DifferentialSearchIndexer' => 'applications/differential/search/DifferentialSearchIndexer.php',
+ 'DifferentialStoredCustomField' => 'applications/differential/customfield/DifferentialStoredCustomField.php',
'DifferentialSubscribersField' => 'applications/differential/customfield/DifferentialSubscribersField.php',
'DifferentialSummaryField' => 'applications/differential/customfield/DifferentialSummaryField.php',
'DifferentialSummaryFieldSpecification' => 'applications/differential/field/specification/DifferentialSummaryFieldSpecification.php',
@@ -2891,6 +2896,7 @@
'DifferentialAuditorsFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialAuthorField' => 'DifferentialCustomField',
'DifferentialAuthorFieldSpecification' => 'DifferentialFieldSpecification',
+ 'DifferentialBlameRevisionField' => 'DifferentialStoredCustomField',
'DifferentialBlameRevisionFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialBranchFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialCCWelcomeMail' => 'DifferentialReviewRequestMail',
@@ -2962,6 +2968,7 @@
'DifferentialFieldValidationException' => 'Exception',
'DifferentialFreeformFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialGitSVNIDFieldSpecification' => 'DifferentialFieldSpecification',
+ 'DifferentialHostField' => 'DifferentialCustomField',
'DifferentialHostFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialHovercardEventListener' => 'PhabricatorEventListener',
'DifferentialHunk' => 'DifferentialDAO',
@@ -2973,7 +2980,7 @@
'DifferentialInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController',
'DifferentialInlineCommentQuery' => 'PhabricatorOffsetPagedQuery',
'DifferentialInlineCommentView' => 'AphrontView',
- 'DifferentialJIRAIssuesField' => 'DifferentialCustomField',
+ 'DifferentialJIRAIssuesField' => 'DifferentialStoredCustomField',
'DifferentialJIRAIssuesFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialLandingActionMenuEventListener' => 'PhabricatorEventListener',
'DifferentialLandingToGitHub' => 'DifferentialLandingStrategy',
@@ -2990,6 +2997,7 @@
'DifferentialPHIDTypeRevision' => 'PhabricatorPHIDType',
'DifferentialParseCacheGarbageCollector' => 'PhabricatorGarbageCollector',
'DifferentialParseRenderTestCase' => 'PhabricatorTestCase',
+ 'DifferentialPathField' => 'DifferentialCustomField',
'DifferentialPathFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialPrimaryPaneView' => 'AphrontView',
'DifferentialProjectReviewersField' => 'DifferentialCustomField',
@@ -3001,6 +3009,7 @@
'DifferentialRepositoryFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialRepositoryLookup' => 'Phobject',
'DifferentialResultsTableView' => 'AphrontView',
+ 'DifferentialRevertPlanField' => 'DifferentialStoredCustomField',
'DifferentialRevertPlanFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialReviewRequestMail' => 'DifferentialMail',
'DifferentialReviewedByFieldSpecification' => 'DifferentialFieldSpecification',
@@ -3038,6 +3047,7 @@
'DifferentialRevisionUpdateHistoryView' => 'AphrontView',
'DifferentialRevisionViewController' => 'DifferentialController',
'DifferentialSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
+ 'DifferentialStoredCustomField' => 'DifferentialCustomField',
'DifferentialSubscribersField' => 'DifferentialCoreCustomField',
'DifferentialSummaryField' => 'DifferentialCoreCustomField',
'DifferentialSummaryFieldSpecification' => 'DifferentialFreeformFieldSpecification',
diff --git a/src/applications/differential/customfield/DifferentialBlameRevisionField.php b/src/applications/differential/customfield/DifferentialBlameRevisionField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/customfield/DifferentialBlameRevisionField.php
@@ -0,0 +1,83 @@
+<?php
+
+final class DifferentialBlameRevisionField
+ extends DifferentialStoredCustomField {
+
+ public function getFieldKey() {
+ return 'phabricator:blame-revision';
+ }
+
+ public function getFieldName() {
+ return pht('Blame Revision');
+ }
+
+ public function getFieldDescription() {
+ return pht('Stores a reference to what this fixes.');
+ }
+
+ public function shouldAppearInPropertyView() {
+ return true;
+ }
+
+ public function renderPropertyViewLabel() {
+ return $this->getFieldName();
+ }
+
+ public function renderPropertyViewValue(array $handles) {
+ return $this->getValue();
+ }
+
+ public function shouldAppearInEditView() {
+ return true;
+ }
+
+ public function shouldAppearInApplicationTransactions() {
+ return true;
+ }
+
+ public function getOldValueForApplicationTransactions() {
+ return $this->getValue();
+ }
+
+ public function getNewValueForApplicationTransactions() {
+ return $this->getValue();
+ }
+
+ public function readValueFromRequest(AphrontRequest $request) {
+ $this->setValue($request->getStr($this->getFieldKey()));
+ }
+
+ public function renderEditControl(array $handles) {
+ return id(new AphrontFormTextControl())
+ ->setName($this->getFieldKey())
+ ->setValue($this->getValue())
+ ->setLabel($this->getFieldName());
+ }
+
+ public function getApplicationTransactionTitle(
+ PhabricatorApplicationTransaction $xaction) {
+ $author_phid = $xaction->getAuthorPHID();
+ $old = $xaction->getOldValue();
+ $new = $xaction->getNewValue();
+
+ return pht(
+ '%s updated the blame revision for this revision.',
+ $xaction->renderHandleLink($author_phid));
+ }
+
+ public function getApplicationTransactionTitleForFeed(
+ PhabricatorApplicationTransaction $xaction,
+ PhabricatorFeedStory $story) {
+
+ $object_phid = $xaction->getObjectPHID();
+ $author_phid = $xaction->getAuthorPHID();
+ $old = $xaction->getOldValue();
+ $new = $xaction->getNewValue();
+
+ return pht(
+ '%s updated the blame revision for %s.',
+ $xaction->renderHandleLink($author_phid),
+ $xaction->renderHandleLink($object_phid));
+ }
+
+}
diff --git a/src/applications/differential/customfield/DifferentialHostField.php b/src/applications/differential/customfield/DifferentialHostField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/customfield/DifferentialHostField.php
@@ -0,0 +1,35 @@
+<?php
+
+final class DifferentialHostField
+ extends DifferentialCustomField {
+
+ public function getFieldKey() {
+ return 'differential:host';
+ }
+
+ public function getFieldName() {
+ return pht('Host');
+ }
+
+ public function getFieldDescription() {
+ return pht('Shows the local host where the diff came from.');
+ }
+
+ public function shouldAppearInPropertyView() {
+ return true;
+ }
+
+ public function renderPropertyViewLabel() {
+ return $this->getFieldName();
+ }
+
+ public function renderPropertyViewValue(array $handles) {
+ $host = $this->getObject()->getActiveDiff()->getSourceMachine();
+ if (!$host) {
+ return null;
+ }
+
+ return $host;
+ }
+
+}
diff --git a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
--- a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
+++ b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
@@ -1,14 +1,19 @@
<?php
final class DifferentialJIRAIssuesField
- extends DifferentialCustomField {
+ extends DifferentialStoredCustomField {
- // TODO: This field needs to actually read storage!
- private $value = null;
+ public function getFieldKey() {
+ return 'phabricator:jira-issues';
+ }
+ public function getValueForStorage() {
+ return json_encode($this->getValue());
+ }
- public function getFieldKey() {
- return 'differential:jira-issues';
+ public function setValueFromStorage($value) {
+ $this->setValue(json_decode($value, true));
+ return $this;
}
public function getFieldName() {
@@ -46,8 +51,8 @@
$provider = PhabricatorAuthProviderOAuth1JIRA::getJIRAProvider();
$refs = array();
- if ($this->value) {
- foreach ($this->value as $jira_key) {
+ if ($this->getValue()) {
+ foreach ($this->getValue() as $jira_key) {
$refs[] = id(new DoorkeeperObjectRef())
->setApplicationType(DoorkeeperBridgeJIRA::APPTYPE_JIRA)
->setApplicationDomain($provider->getProviderDomain())
@@ -66,11 +71,13 @@
}
$xobjs = id(new DoorkeeperExternalObjectQuery())
- ->setViewer($this->getUser())
+ ->setViewer($this->getViewer())
->withObjectKeys(mpull($refs, 'getObjectKey'))
->execute();
return $xobjs;
}
+ // TODO: Implement edit; this field is readonly for now.
+
}
diff --git a/src/applications/differential/customfield/DifferentialPathField.php b/src/applications/differential/customfield/DifferentialPathField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/customfield/DifferentialPathField.php
@@ -0,0 +1,35 @@
+<?php
+
+final class DifferentialPathField
+ extends DifferentialCustomField {
+
+ public function getFieldKey() {
+ return 'differential:path';
+ }
+
+ public function getFieldName() {
+ return pht('Path');
+ }
+
+ public function getFieldDescription() {
+ return pht('Shows the local path where the diff came from.');
+ }
+
+ public function shouldAppearInPropertyView() {
+ return true;
+ }
+
+ public function renderPropertyViewLabel() {
+ return $this->getFieldName();
+ }
+
+ public function renderPropertyViewValue(array $handles) {
+ $path = $this->getObject()->getActiveDiff()->getSourcePath();
+ if (!$path) {
+ return null;
+ }
+
+ return $path;
+ }
+
+}
diff --git a/src/applications/differential/customfield/DifferentialTestPlanField.php b/src/applications/differential/customfield/DifferentialRevertPlanField.php
copy from src/applications/differential/customfield/DifferentialTestPlanField.php
copy to src/applications/differential/customfield/DifferentialRevertPlanField.php
--- a/src/applications/differential/customfield/DifferentialTestPlanField.php
+++ b/src/applications/differential/customfield/DifferentialRevertPlanField.php
@@ -1,43 +1,74 @@
<?php
-final class DifferentialTestPlanField
- extends DifferentialCoreCustomField {
+final class DifferentialRevertPlanField
+ extends DifferentialStoredCustomField {
public function getFieldKey() {
- return 'differential:test-plan';
+ return 'phabricator:revert-plan';
}
public function getFieldName() {
- return pht('Test Plan');
+ return pht('Revert Plan');
}
public function getFieldDescription() {
- return pht('Actions performed to verify the behavior of the change.');
+ return pht('Instructions for reverting/undoing this change.');
}
- protected function readValueFromRevision(
- DifferentialRevision $revision) {
- return $revision->getTestPlan();
+ public function shouldAppearInPropertyView() {
+ return true;
+ }
+
+ public function renderPropertyViewLabel() {
+ return $this->getFieldName();
}
- protected function writeValueToRevision(
- DifferentialRevision $revision,
- $value) {
- $revision->setTestPlan($value);
+ public function getStyleForPropertyView() {
+ return 'block';
}
- protected function isCoreFieldRequired() {
- return PhabricatorEnv::getEnvConfig('differential.require-test-plan-field');
+ public function getIconForPropertyView() {
+ return PHUIPropertyListView::ICON_TESTPLAN;
}
- public function canDisableField() {
+ public function renderPropertyViewValue(array $handles) {
+ if (!strlen($this->getValue())) {
+ return null;
+ }
+
+ return PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())
+ ->setPreserveLinebreaks(true)
+ ->setContent($this->getValue()),
+ 'default',
+ $this->getViewer());
+ }
+
+ public function shouldAppearInGlobalSearch() {
return true;
}
- protected function getCoreFieldRequiredErrorString() {
- return pht(
- 'You must provide a test plan: describe the actions you performed '.
- 'to verify the behvaior of this change.');
+ public function updateAbstractDocument(
+ PhabricatorSearchAbstractDocument $document) {
+ if (strlen($this->getValue())) {
+ $document->addField('rvrt', $this->getValue());
+ }
+ }
+
+ public function shouldAppearInEditView() {
+ return true;
+ }
+
+ public function shouldAppearInApplicationTransactions() {
+ return true;
+ }
+
+ public function getOldValueForApplicationTransactions() {
+ return $this->getValue();
+ }
+
+ public function getNewValueForApplicationTransactions() {
+ return $this->getValue();
}
public function readValueFromRequest(AphrontRequest $request) {
@@ -48,7 +79,6 @@
return id(new PhabricatorRemarkupControl())
->setName($this->getFieldKey())
->setValue($this->getValue())
- ->setError($this->getFieldError())
->setLabel($this->getFieldName());
}
@@ -59,7 +89,7 @@
$new = $xaction->getNewValue();
return pht(
- '%s updated the test plan for this revision.',
+ '%s updated the revert plan for this revision.',
$xaction->renderHandleLink($author_phid));
}
@@ -73,7 +103,7 @@
$new = $xaction->getNewValue();
return pht(
- '%s updated the test plan for %s.',
+ '%s updated the revert plan for %s.',
$xaction->renderHandleLink($author_phid),
$xaction->renderHandleLink($object_phid));
}
@@ -92,16 +122,4 @@
$xaction->getNewValue());
}
-
- public function shouldAppearInGlobalSearch() {
- return true;
- }
-
- public function updateAbstractDocument(
- PhabricatorSearchAbstractDocument $document) {
- if (strlen($this->getValue())) {
- $document->addField('plan', $this->getValue());
- }
- }
-
}
diff --git a/src/applications/differential/customfield/DifferentialStoredCustomField.php b/src/applications/differential/customfield/DifferentialStoredCustomField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/customfield/DifferentialStoredCustomField.php
@@ -0,0 +1,42 @@
+<?php
+
+abstract class DifferentialStoredCustomField
+ extends DifferentialCustomField {
+
+ private $value;
+
+ public function setValue($value) {
+ $this->value = $value;
+ return $this;
+ }
+
+ public function getValue() {
+ return $this->value;
+ }
+
+ public function shouldUseStorage() {
+ return true;
+ }
+
+ public function newStorageObject() {
+ return new DifferentialCustomFieldStorage();
+ }
+
+ protected function newStringIndexStorage() {
+ return new DifferentialCustomFieldStringIndex();
+ }
+
+ protected function newNumericIndexStorage() {
+ return new DifferentialCustomFieldNumericIndex();
+ }
+
+ public function getValueForStorage() {
+ return $this->value;
+ }
+
+ public function setValueFromStorage($value) {
+ $this->value = $value;
+ return $this;
+ }
+
+}
diff --git a/src/applications/differential/customfield/DifferentialSummaryField.php b/src/applications/differential/customfield/DifferentialSummaryField.php
--- a/src/applications/differential/customfield/DifferentialSummaryField.php
+++ b/src/applications/differential/customfield/DifferentialSummaryField.php
@@ -89,4 +89,33 @@
}
}
+ public function shouldAppearInPropertyView() {
+ return true;
+ }
+
+ public function renderPropertyViewLabel() {
+ return $this->getFieldName();
+ }
+
+ public function getStyleForPropertyView() {
+ return 'block';
+ }
+
+ public function getIconForPropertyView() {
+ return PHUIPropertyListView::ICON_SUMMARY;
+ }
+
+ public function renderPropertyViewValue(array $handles) {
+ if (!strlen($this->getValue())) {
+ return null;
+ }
+
+ return PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())
+ ->setPreserveLinebreaks(true)
+ ->setContent($this->getValue()),
+ 'default',
+ $this->getViewer());
+ }
+
}
diff --git a/src/applications/differential/customfield/DifferentialTestPlanField.php b/src/applications/differential/customfield/DifferentialTestPlanField.php
--- a/src/applications/differential/customfield/DifferentialTestPlanField.php
+++ b/src/applications/differential/customfield/DifferentialTestPlanField.php
@@ -104,4 +104,33 @@
}
}
+ public function shouldAppearInPropertyView() {
+ return true;
+ }
+
+ public function renderPropertyViewLabel() {
+ return $this->getFieldName();
+ }
+
+ public function getStyleForPropertyView() {
+ return 'block';
+ }
+
+ public function getIconForPropertyView() {
+ return PHUIPropertyListView::ICON_TESTPLAN;
+ }
+
+ public function renderPropertyViewValue(array $handles) {
+ if (!strlen($this->getValue())) {
+ return null;
+ }
+
+ return PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())
+ ->setPreserveLinebreaks(true)
+ ->setContent($this->getValue()),
+ 'default',
+ $this->getViewer());
+ }
+
}
diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php
--- a/src/applications/differential/storage/DifferentialRevision.php
+++ b/src/applications/differential/storage/DifferentialRevision.php
@@ -73,6 +73,11 @@
) + parent::getConfiguration();
}
+ public function getMonogram() {
+ $id = $this->getID();
+ return "D{$id}";
+ }
+
public function setTitle($title) {
$this->title = $title;
if (!$this->getID()) {
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomField.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php
@@ -278,6 +278,10 @@
return true;
}
+ public function shouldDisableByDefault() {
+ return false;
+ }
+
/**
* Return an index string which uniquely identifies this field.
@@ -1073,6 +1077,17 @@
/**
* @task view
*/
+ public function getIconForPropertyView() {
+ if ($this->proxy) {
+ return $this->proxy->getIconForPropertyView();
+ }
+ return null;
+ }
+
+
+ /**
+ * @task view
+ */
public function getRequiredHandlePHIDsForPropertyView() {
if ($this->proxy) {
return $this->proxy->getRequiredHandlePHIDsForPropertyView();
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
@@ -199,9 +199,10 @@
$view->addProperty($label, $value);
break;
case 'block':
+ $icon = $field->getIconForPropertyView();
$view->invokeWillRenderEvent();
if ($label !== null) {
- $view->addSectionHeader($label);
+ $view->addSectionHeader($label, $icon);
}
$view->addTextContent($value);
break;

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 10:44 AM (17 h, 44 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6913656
Default Alt Text
D8357.id19865.diff (22 KB)

Event Timeline