Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php
index 2c5c936679..d45fc22fd3 100644
--- a/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php
+++ b/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php
@@ -1,166 +1,168 @@
<?php
final class DifferentialGetCommitMessageConduitAPIMethod
extends DifferentialConduitAPIMethod {
public function getAPIMethodName() {
return 'differential.getcommitmessage';
}
public function getMethodDescription() {
return pht('Retrieve Differential commit messages or message templates.');
}
protected function defineParamTypes() {
$edit_types = array('edit', 'create');
return array(
'revision_id' => 'optional revision_id',
'fields' => 'optional dict<string, wild>',
'edit' => 'optional '.$this->formatStringConstants($edit_types),
);
}
protected function defineReturnType() {
return 'nonempty string';
}
protected function defineErrorTypes() {
return array(
'ERR_NOT_FOUND' => pht('Revision was not found.'),
);
}
protected function execute(ConduitAPIRequest $request) {
$id = $request->getValue('revision_id');
$viewer = $request->getUser();
if ($id) {
$revision = id(new DifferentialRevisionQuery())
->withIDs(array($id))
->setViewer($viewer)
->needReviewerStatus(true)
->needActiveDiffs(true)
->executeOne();
if (!$revision) {
throw new ConduitException('ERR_NOT_FOUND');
}
} else {
$revision = DifferentialRevision::initializeNewRevision($viewer);
}
// There are three modes here: "edit", "create", and "read" (which has
// no value for the "edit" parameter).
// In edit or create mode, we hide read-only fields. In create mode, we
// show "Field:" templates for some fields even if they are empty.
$edit_mode = $request->getValue('edit');
$is_any_edit = (bool)strlen($edit_mode);
$is_create = ($edit_mode == 'create');
$field_list = DifferentialCommitMessageField::newEnabledFields($viewer);
$custom_storage = $this->loadCustomFieldStorage($viewer, $revision);
foreach ($field_list as $field) {
$field->setCustomFieldStorage($custom_storage);
}
// If we're editing the message, remove fields like "Conflicts" and
// "git-svn-id" which should not be presented to the user for editing.
if ($is_any_edit) {
foreach ($field_list as $field_key => $field) {
if (!$field->isFieldEditable()) {
unset($field_list[$field_key]);
}
}
}
$overrides = $request->getValue('fields', array());
$value_map = array();
foreach ($field_list as $field_key => $field) {
if (array_key_exists($field_key, $overrides)) {
$field_value = $overrides[$field_key];
} else {
$field_value = $field->readFieldValueFromObject($revision);
}
// We're calling this method on the value no matter where we got it
// from, so we hit the same validation logic for values which came over
// the wire and which we generated.
$field_value = $field->readFieldValueFromConduit($field_value);
$value_map[$field_key] = $field_value;
}
$key_title = DifferentialTitleCommitMessageField::FIELDKEY;
$commit_message = array();
foreach ($field_list as $field_key => $field) {
$label = $field->getFieldName();
$wire_value = $value_map[$field_key];
$value = $field->renderFieldValue($wire_value);
$is_template = ($is_create && $field->isTemplateField());
if (!is_string($value) && !is_null($value)) {
throw new Exception(
pht(
'Commit message field "%s" was expected to render a string or '.
'null value, but rendered a "%s" instead.',
$field->getFieldKey(),
gettype($value)));
}
$is_title = ($field_key == $key_title);
if (!strlen($value)) {
if ($is_template) {
$commit_message[] = $label.': ';
}
} else {
if ($is_title) {
$commit_message[] = $value;
} else {
$value = str_replace(
array("\r\n", "\r"),
array("\n", "\n"),
$value);
if (strpos($value, "\n") !== false || substr($value, 0, 2) === ' ') {
$commit_message[] = "{$label}:\n{$value}";
} else {
$commit_message[] = "{$label}: {$value}";
}
}
}
}
return implode("\n\n", $commit_message);
}
private function loadCustomFieldStorage(
PhabricatorUser $viewer,
DifferentialRevision $revision) {
+
$custom_field_list = PhabricatorCustomField::getObjectFields(
$revision,
- DifferentialCustomField::ROLE_COMMITMESSAGE);
+ PhabricatorCustomField::ROLE_STORAGE);
+
$custom_field_list
->setViewer($viewer)
->readFieldsFromStorage($revision);
$custom_field_map = array();
foreach ($custom_field_list->getFields() as $custom_field) {
if (!$custom_field->shouldUseStorage()) {
continue;
}
$custom_field_key = $custom_field->getFieldKey();
$custom_field_value = $custom_field->getValueForStorage();
$custom_field_map[$custom_field_key] = $custom_field_value;
}
return $custom_field_map;
}
}
diff --git a/src/applications/differential/customfield/DifferentialAuditorsField.php b/src/applications/differential/customfield/DifferentialAuditorsField.php
index 544f238458..23055461e0 100644
--- a/src/applications/differential/customfield/DifferentialAuditorsField.php
+++ b/src/applications/differential/customfield/DifferentialAuditorsField.php
@@ -1,55 +1,51 @@
<?php
final class DifferentialAuditorsField
extends DifferentialStoredCustomField {
public function getFieldKey() {
return 'phabricator:auditors';
}
public function getFieldName() {
return pht('Auditors');
}
public function getFieldDescription() {
return pht('Allows commits to trigger audits explicitly.');
}
public function getValueForStorage() {
return phutil_json_encode($this->getValue());
}
public function setValueFromStorage($value) {
try {
$this->setValue(phutil_json_decode($value));
} catch (PhutilJSONParserException $ex) {
$this->setValue(array());
}
return $this;
}
public function canDisableField() {
return false;
}
public function shouldAppearInEditEngine() {
return true;
}
- public function shouldAppearInCommitMessage() {
- return true;
- }
-
public function shouldAppearInConduitTransactions() {
return true;
}
protected function newConduitEditParameterType() {
return new ConduitPHIDListParameterType();
}
public function shouldAppearInApplicationTransactions() {
return true;
}
}
diff --git a/src/applications/differential/customfield/DifferentialBlameRevisionField.php b/src/applications/differential/customfield/DifferentialBlameRevisionField.php
index b2d8872225..d36e199b1a 100644
--- a/src/applications/differential/customfield/DifferentialBlameRevisionField.php
+++ b/src/applications/differential/customfield/DifferentialBlameRevisionField.php
@@ -1,110 +1,106 @@
<?php
final class DifferentialBlameRevisionField
extends DifferentialStoredCustomField {
public function getFieldKey() {
return 'phabricator:blame-revision';
}
public function getFieldKeyForConduit() {
return 'blameRevision';
}
public function getFieldName() {
return pht('Blame Revision');
}
public function getFieldDescription() {
return pht('Stores a reference to what this fixes.');
}
public function shouldDisableByDefault() {
return true;
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
if (!strlen($this->getValue())) {
return null;
}
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) {
$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));
}
- public function shouldAppearInCommitMessage() {
- return true;
- }
-
public function shouldAppearInConduitDictionary() {
return true;
}
public function shouldAppearInConduitTransactions() {
return true;
}
protected function newConduitEditParameterType() {
return new ConduitStringParameterType();
}
}
diff --git a/src/applications/differential/customfield/DifferentialCoreCustomField.php b/src/applications/differential/customfield/DifferentialCoreCustomField.php
index d4181a31e7..6d956ac367 100644
--- a/src/applications/differential/customfield/DifferentialCoreCustomField.php
+++ b/src/applications/differential/customfield/DifferentialCoreCustomField.php
@@ -1,172 +1,163 @@
<?php
/**
* Base class for Differential fields with storage on the revision object
* itself. This mostly wraps reading/writing field values to and from the
* object.
*/
abstract class DifferentialCoreCustomField
extends DifferentialCustomField {
private $value;
private $fieldError;
private $fieldParser;
abstract protected function readValueFromRevision(
DifferentialRevision $revision);
protected function writeValueToRevision(
DifferentialRevision $revision,
$value) {
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
protected function isCoreFieldRequired() {
return false;
}
protected function isCoreFieldValueEmpty($value) {
if (is_array($value)) {
return !$value;
}
return !strlen(trim($value));
}
protected function getCoreFieldRequiredErrorString() {
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
public function validateApplicationTransactions(
PhabricatorApplicationTransactionEditor $editor,
$type,
array $xactions) {
$this->setFieldError(null);
$errors = parent::validateApplicationTransactions(
$editor,
$type,
$xactions);
$transaction = null;
foreach ($xactions as $xaction) {
$value = $xaction->getNewValue();
if ($this->isCoreFieldRequired()) {
if ($this->isCoreFieldValueEmpty($value)) {
$error = new PhabricatorApplicationTransactionValidationError(
$type,
pht('Required'),
$this->getCoreFieldRequiredErrorString(),
$xaction);
$error->setIsMissingFieldError(true);
$errors[] = $error;
$this->setFieldError(pht('Required'));
continue;
}
}
if (is_string($value)) {
$parser = $this->getFieldParser();
$result = $parser->parseCorpus($value);
unset($result['__title__']);
unset($result['__summary__']);
if ($result) {
$error = new PhabricatorApplicationTransactionValidationError(
$type,
pht('Invalid'),
pht(
'The value you have entered in "%s" can not be parsed '.
'unambiguously when rendered in a commit message. Edit the '.
'message so that keywords like "Summary:" and "Test Plan:" do '.
'not appear at the beginning of lines. Parsed keys: %s.',
$this->getFieldName(),
implode(', ', array_keys($result))),
$xaction);
$errors[] = $error;
$this->setFieldError(pht('Invalid'));
continue;
}
}
}
return $errors;
}
private function getFieldParser() {
if (!$this->fieldParser) {
$viewer = $this->getViewer();
$parser = DifferentialCommitMessageParser::newStandardParser($viewer);
// Set custom title and summary keys so we can detect the presence of
// "Summary:" in, e.g., a test plan.
$parser->setTitleKey('__title__');
$parser->setSummaryKey('__summary__');
$this->fieldParser = $parser;
}
return $this->fieldParser;
}
public function canDisableField() {
return false;
}
public function shouldAppearInApplicationTransactions() {
return true;
}
public function readValueFromObject(PhabricatorCustomFieldInterface $object) {
if ($this->isCoreFieldRequired()) {
$this->setFieldError(true);
}
$this->setValue($this->readValueFromRevision($object));
}
public function getOldValueForApplicationTransactions() {
return $this->readValueFromRevision($this->getObject());
}
public function getNewValueForApplicationTransactions() {
return $this->getValue();
}
public function applyApplicationTransactionInternalEffects(
PhabricatorApplicationTransaction $xaction) {
$this->writeValueToRevision($this->getObject(), $xaction->getNewValue());
}
public function setFieldError($field_error) {
$this->fieldError = $field_error;
return $this;
}
public function getFieldError() {
return $this->fieldError;
}
public function setValue($value) {
$this->value = $value;
return $this;
}
public function getValue() {
return $this->value;
}
- public function readValueFromCommitMessage($value) {
- $this->setValue($value);
- return $this;
- }
-
- public function renderCommitMessageValue(array $handles) {
- return $this->getValue();
- }
-
public function getConduitDictionaryValue() {
return $this->getValue();
}
}
diff --git a/src/applications/differential/customfield/DifferentialCustomField.php b/src/applications/differential/customfield/DifferentialCustomField.php
index f210dd0f63..487e412f66 100644
--- a/src/applications/differential/customfield/DifferentialCustomField.php
+++ b/src/applications/differential/customfield/DifferentialCustomField.php
@@ -1,268 +1,131 @@
<?php
/**
* @task commitmessage Integration with Commit Messages
* @task diff Integration with Diff Properties
*/
abstract class DifferentialCustomField
extends PhabricatorCustomField {
- const ROLE_COMMITMESSAGE = 'differential:commitmessage';
- const ROLE_COMMITMESSAGEEDIT = 'differential:commitmessageedit';
-
/**
* TODO: It would be nice to remove this, but a lot of different code is
* bound together by it. Until everything is modernized, retaining the old
* field keys is the only reasonable way to update things one piece
* at a time.
*/
public function getFieldKeyForConduit() {
return $this->getFieldKey();
}
// TODO: As above.
public function getModernFieldKey() {
return $this->getFieldKeyForConduit();
}
- public function shouldEnableForRole($role) {
- switch ($role) {
- case self::ROLE_COMMITMESSAGE:
- return $this->shouldAppearInCommitMessage();
- case self::ROLE_COMMITMESSAGEEDIT:
- return $this->shouldAppearInCommitMessage() &&
- $this->shouldAllowEditInCommitMessage();
- }
-
- return parent::shouldEnableForRole($role);
- }
-
protected function parseObjectList(
$value,
array $types,
$allow_partial = false,
array $suffixes = array()) {
return id(new PhabricatorObjectListQuery())
->setViewer($this->getViewer())
->setAllowedTypes($types)
->setObjectList($value)
->setAllowPartialResults($allow_partial)
->setSuffixes($suffixes)
->execute();
}
protected function renderObjectList(
array $handles,
array $suffixes = array()) {
if (!$handles) {
return null;
}
$out = array();
foreach ($handles as $handle) {
$phid = $handle->getPHID();
if ($handle->getPolicyFiltered()) {
$token = $phid;
} else if ($handle->isComplete()) {
$token = $handle->getCommandLineObjectName();
}
$suffix = idx($suffixes, $phid);
$token = $token.$suffix;
$out[] = $token;
}
return implode(', ', $out);
}
public function getWarningsForDetailView() {
if ($this->getProxy()) {
return $this->getProxy()->getWarningsForDetailView();
}
return array();
}
public function getRequiredHandlePHIDsForRevisionHeaderWarnings() {
return array();
}
public function getWarningsForRevisionHeader(array $handles) {
return array();
}
/* -( Integration with Commit Messages )----------------------------------- */
- /**
- * @task commitmessage
- */
- public function shouldAppearInCommitMessage() {
- if ($this->getProxy()) {
- return $this->getProxy()->shouldAppearInCommitMessage();
- }
- return false;
- }
-
-
- /**
- * @task commitmessage
- */
- public function shouldAppearInCommitMessageTemplate() {
- if ($this->getProxy()) {
- return $this->getProxy()->shouldAppearInCommitMessageTemplate();
- }
- return false;
- }
-
-
- /**
- * @task commitmessage
- */
- public function shouldAllowEditInCommitMessage() {
- if ($this->getProxy()) {
- return $this->getProxy()->shouldAllowEditInCommitMessage();
- }
- return true;
- }
-
-
/**
* @task commitmessage
*/
public function getProTips() {
if ($this->getProxy()) {
return $this->getProxy()->getProTips();
}
return array();
}
- /**
- * @task commitmessage
- */
- public function getCommitMessageLabels() {
- if ($this->getProxy()) {
- return $this->getProxy()->getCommitMessageLabels();
- }
- return array($this->renderCommitMessageLabel());
- }
-
-
- /**
- * @task commitmessage
- */
- public function parseValueFromCommitMessage($value) {
- if ($this->getProxy()) {
- return $this->getProxy()->parseValueFromCommitMessage($value);
- }
- return $value;
- }
-
-
- /**
- * @task commitmessage
- */
- public function readValueFromCommitMessage($value) {
- if ($this->getProxy()) {
- $this->getProxy()->readValueFromCommitMessage($value);
- return $this;
- }
- return $this;
- }
-
-
- /**
- * @task commitmessage
- */
- public function shouldOverwriteWhenCommitMessageIsEdited() {
- if ($this->getProxy()) {
- return $this->getProxy()->shouldOverwriteWhenCommitMessageIsEdited();
- }
- return false;
- }
-
-
- /**
- * @task commitmessage
- */
- public function getRequiredHandlePHIDsForCommitMessage() {
- if ($this->getProxy()) {
- return $this->getProxy()->getRequiredHandlePHIDsForCommitMessage();
- }
- return array();
- }
-
-
- /**
- * @task commitmessage
- */
- public function renderCommitMessageLabel() {
- if ($this->getProxy()) {
- return $this->getProxy()->renderCommitMessageLabel();
- }
- return $this->getFieldName();
- }
-
-
- /**
- * @task commitmessage
- */
- public function renderCommitMessageValue(array $handles) {
- if ($this->getProxy()) {
- return $this->getProxy()->renderCommitMessageValue($handles);
- }
- throw new PhabricatorCustomFieldImplementationIncompleteException($this);
- }
-
-
- /**
- * @task commitmessage
- */
- public function validateCommitMessageValue($value) {
- if ($this->getProxy()) {
- return $this->getProxy()->validateCommitMessageValue($value);
- }
- return;
- }
-
-
/* -( Integration with Diff Properties )----------------------------------- */
/**
* @task diff
*/
public function shouldAppearInDiffPropertyView() {
if ($this->getProxy()) {
return $this->getProxy()->shouldAppearInDiffPropertyView();
}
return false;
}
/**
* @task diff
*/
public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {
if ($this->proxy) {
return $this->proxy->renderDiffPropertyViewLabel($diff);
}
return $this->getFieldName();
}
/**
* @task diff
*/
public function renderDiffPropertyViewValue(DifferentialDiff $diff) {
if ($this->proxy) {
return $this->proxy->renderDiffPropertyViewValue($diff);
}
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
}
diff --git a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
index fc15f4a45b..e97efd6ad5 100644
--- a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
+++ b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php
@@ -1,318 +1,285 @@
<?php
final class DifferentialJIRAIssuesField
extends DifferentialStoredCustomField {
private $error;
public function getFieldKey() {
return 'phabricator:jira-issues';
}
public function getFieldKeyForConduit() {
return 'jira.issues';
}
public function isFieldEnabled() {
return (bool)PhabricatorJIRAAuthProvider::getJIRAProvider();
}
public function canDisableField() {
return false;
}
public function getValueForStorage() {
return json_encode($this->getValue());
}
public function setValueFromStorage($value) {
try {
$this->setValue(phutil_json_decode($value));
} catch (PhutilJSONParserException $ex) {
$this->setValue(array());
}
return $this;
}
public function getFieldName() {
return pht('JIRA Issues');
}
public function getFieldDescription() {
return pht('Lists associated JIRA issues.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
$xobjs = $this->loadDoorkeeperExternalObjects($this->getValue());
if (!$xobjs) {
return null;
}
$links = array();
foreach ($xobjs as $xobj) {
$links[] = id(new DoorkeeperTagView())
->setExternalObject($xobj);
}
return phutil_implode_html(phutil_tag('br'), $links);
}
private function buildDoorkeeperRefs($value) {
$provider = PhabricatorJIRAAuthProvider::getJIRAProvider();
$refs = array();
if ($value) {
foreach ($value as $jira_key) {
$refs[] = id(new DoorkeeperObjectRef())
->setApplicationType(DoorkeeperBridgeJIRA::APPTYPE_JIRA)
->setApplicationDomain($provider->getProviderDomain())
->setObjectType(DoorkeeperBridgeJIRA::OBJTYPE_ISSUE)
->setObjectID($jira_key);
}
}
return $refs;
}
private function loadDoorkeeperExternalObjects($value) {
$refs = $this->buildDoorkeeperRefs($value);
if (!$refs) {
return array();
}
$xobjs = id(new DoorkeeperExternalObjectQuery())
->setViewer($this->getViewer())
->withObjectKeys(mpull($refs, 'getObjectKey'))
->execute();
return $xobjs;
}
public function shouldAppearInEditView() {
return PhabricatorJIRAAuthProvider::getJIRAProvider();
}
public function shouldAppearInApplicationTransactions() {
return PhabricatorJIRAAuthProvider::getJIRAProvider();
}
public function readValueFromRequest(AphrontRequest $request) {
$this->setValue($request->getStrList($this->getFieldKey()));
return $this;
}
public function renderEditControl(array $handles) {
return id(new AphrontFormTextControl())
->setLabel(pht('JIRA Issues'))
->setCaption(
pht('Example: %s', phutil_tag('tt', array(), 'JIS-3, JIS-9')))
->setName($this->getFieldKey())
->setValue(implode(', ', nonempty($this->getValue(), array())))
->setError($this->error);
}
public function getOldValueForApplicationTransactions() {
return array_unique(nonempty($this->getValue(), array()));
}
public function getNewValueForApplicationTransactions() {
return array_unique(nonempty($this->getValue(), array()));
}
public function validateApplicationTransactions(
PhabricatorApplicationTransactionEditor $editor,
$type,
array $xactions) {
$this->error = null;
$errors = parent::validateApplicationTransactions(
$editor,
$type,
$xactions);
$transaction = null;
foreach ($xactions as $xaction) {
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
$add = array_diff($new, $old);
if (!$add) {
continue;
}
// Only check that the actor can see newly added JIRA refs. You're
// allowed to remove refs or make no-op changes even if you aren't
// linked to JIRA.
try {
$refs = id(new DoorkeeperImportEngine())
->setViewer($this->getViewer())
->setRefs($this->buildDoorkeeperRefs($add))
->setThrowOnMissingLink(true)
->execute();
} catch (DoorkeeperMissingLinkException $ex) {
$this->error = pht('Not Linked');
$errors[] = new PhabricatorApplicationTransactionValidationError(
$type,
pht('Not Linked'),
pht(
'You can not add JIRA issues (%s) to this revision because your '.
'Phabricator account is not linked to a JIRA account.',
implode(', ', $add)),
$xaction);
continue;
}
$bad = array();
foreach ($refs as $ref) {
if (!$ref->getIsVisible()) {
$bad[] = $ref->getObjectID();
}
}
if ($bad) {
$bad = implode(', ', $bad);
$this->error = pht('Invalid');
$errors[] = new PhabricatorApplicationTransactionValidationError(
$type,
pht('Invalid'),
pht(
'Some JIRA issues could not be loaded. They may not exist, or '.
'you may not have permission to view them: %s',
$bad),
$xaction);
}
}
return $errors;
}
public function getApplicationTransactionTitle(
PhabricatorApplicationTransaction $xaction) {
$old = $xaction->getOldValue();
if (!is_array($old)) {
$old = array();
}
$new = $xaction->getNewValue();
if (!is_array($new)) {
$new = array();
}
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
$author_phid = $xaction->getAuthorPHID();
if ($add && $rem) {
return pht(
'%s updated JIRA issue(s): added %d %s; removed %d %s.',
$xaction->renderHandleLink($author_phid),
phutil_count($add),
implode(', ', $add),
phutil_count($rem),
implode(', ', $rem));
} else if ($add) {
return pht(
'%s added %d JIRA issue(s): %s.',
$xaction->renderHandleLink($author_phid),
phutil_count($add),
implode(', ', $add));
} else if ($rem) {
return pht(
'%s removed %d JIRA issue(s): %s.',
$xaction->renderHandleLink($author_phid),
phutil_count($rem),
implode(', ', $rem));
}
return parent::getApplicationTransactionTitle($xaction);
}
public function applyApplicationTransactionExternalEffects(
PhabricatorApplicationTransaction $xaction) {
// Update the CustomField storage.
parent::applyApplicationTransactionExternalEffects($xaction);
// Now, synchronize the Doorkeeper edges.
$revision = $this->getObject();
$revision_phid = $revision->getPHID();
$edge_type = PhabricatorJiraIssueHasObjectEdgeType::EDGECONST;
$xobjs = $this->loadDoorkeeperExternalObjects($xaction->getNewValue());
$edge_dsts = mpull($xobjs, 'getPHID');
$edges = PhabricatorEdgeQuery::loadDestinationPHIDs(
$revision_phid,
$edge_type);
$editor = new PhabricatorEdgeEditor();
foreach (array_diff($edges, $edge_dsts) as $rem_edge) {
$editor->removeEdge($revision_phid, $edge_type, $rem_edge);
}
foreach (array_diff($edge_dsts, $edges) as $add_edge) {
$editor->addEdge($revision_phid, $edge_type, $add_edge);
}
$editor->save();
}
- public function shouldAppearInCommitMessage() {
- return true;
- }
-
- public function shouldAppearInCommitMessageTemplate() {
- return true;
- }
-
- public function getCommitMessageLabels() {
- return array(
- 'JIRA',
- 'JIRA Issues',
- 'JIRA Issue',
- );
- }
-
- public function parseValueFromCommitMessage($value) {
- return preg_split('/[\s,]+/', $value, $limit = -1, PREG_SPLIT_NO_EMPTY);
- }
-
- public function readValueFromCommitMessage($value) {
- $this->setValue($value);
- return $this;
- }
-
- public function renderCommitMessageValue(array $handles) {
- $value = $this->getValue();
- if (!$value) {
- return null;
- }
- return implode(', ', $value);
- }
-
public function shouldAppearInConduitDictionary() {
return true;
}
public function shouldAppearInConduitTransactions() {
return true;
}
protected function newConduitEditParameterType() {
return new ConduitStringListParameterType();
}
}
diff --git a/src/applications/differential/customfield/DifferentialRevertPlanField.php b/src/applications/differential/customfield/DifferentialRevertPlanField.php
index 0fd5531426..ca13788294 100644
--- a/src/applications/differential/customfield/DifferentialRevertPlanField.php
+++ b/src/applications/differential/customfield/DifferentialRevertPlanField.php
@@ -1,153 +1,145 @@
<?php
final class DifferentialRevertPlanField
extends DifferentialStoredCustomField {
public function getFieldKey() {
return 'phabricator:revert-plan';
}
public function getFieldKeyForConduit() {
return 'revertPlan';
}
public function getFieldName() {
return pht('Revert Plan');
}
public function getFieldDescription() {
return pht('Instructions for reverting/undoing this change.');
}
public function shouldDisableByDefault() {
return true;
}
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 new PHUIRemarkupView($this->getViewer(), $this->getValue());
}
public function shouldAppearInGlobalSearch() {
return true;
}
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) {
$this->setValue($request->getStr($this->getFieldKey()));
}
public function renderEditControl(array $handles) {
return id(new PhabricatorRemarkupControl())
->setUser($this->getViewer())
->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 revert plan for this revision.',
$xaction->renderHandleLink($author_phid));
}
public function getApplicationTransactionTitleForFeed(
PhabricatorApplicationTransaction $xaction) {
$object_phid = $xaction->getObjectPHID();
$author_phid = $xaction->getAuthorPHID();
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
return pht(
'%s updated the revert plan for %s.',
$xaction->renderHandleLink($author_phid),
$xaction->renderHandleLink($object_phid));
}
public function getApplicationTransactionHasChangeDetails(
PhabricatorApplicationTransaction $xaction) {
return true;
}
public function getApplicationTransactionChangeDetails(
PhabricatorApplicationTransaction $xaction,
PhabricatorUser $viewer) {
return $xaction->renderTextCorpusChangeDetails(
$viewer,
$xaction->getOldValue(),
$xaction->getNewValue());
}
public function getApplicationTransactionRemarkupBlocks(
PhabricatorApplicationTransaction $xaction) {
return array($xaction->getNewValue());
}
- public function shouldAppearInCommitMessage() {
- return true;
- }
-
- public function renderCommitMessageValue(array $handles) {
- return $this->getValue();
- }
-
public function shouldAppearInConduitDictionary() {
return true;
}
public function shouldAppearInConduitTransactions() {
return true;
}
protected function newConduitEditParameterType() {
return new ConduitStringParameterType();
}
}
diff --git a/src/applications/differential/field/DifferentialCommitMessageCustomField.php b/src/applications/differential/field/DifferentialCommitMessageCustomField.php
index cfa71a2a58..21f21e1774 100644
--- a/src/applications/differential/field/DifferentialCommitMessageCustomField.php
+++ b/src/applications/differential/field/DifferentialCommitMessageCustomField.php
@@ -1,72 +1,72 @@
<?php
abstract class DifferentialCommitMessageCustomField
extends DifferentialCommitMessageField {
abstract public function getCustomFieldKey();
public function getFieldOrder() {
$custom_key = $this->getCustomFieldKey();
return 100000 + $this->getCustomFieldOrder($custom_key);
}
public function isFieldEnabled() {
$custom_key = $this->getCustomFieldKey();
return $this->isCustomFieldEnabled($custom_key);
}
public function readFieldValueFromObject(DifferentialRevision $revision) {
$custom_key = $this->getCustomFieldKey();
$value = $this->readCustomFieldValue($revision, $custom_key);
return $value;
}
protected function readFieldValueFromCustomFieldStorage($value) {
return $value;
}
protected function readJSONFieldValueFromCustomFieldStorage(
$value,
$default) {
try {
return phutil_json_decode($value);
} catch (PhutilJSONParserException $ex) {
return $default;
}
}
protected function readCustomFieldValue(
DifferentialRevision $revision,
$key) {
$value = idx($this->getCustomFieldStorage(), $key);
return $this->readFieldValueFromCustomFieldStorage($value);
}
protected function getCustomFieldOrder($key) {
$field_list = PhabricatorCustomField::getObjectFields(
new DifferentialRevision(),
- DifferentialCustomField::ROLE_COMMITMESSAGE);
+ PhabricatorCustomField::ROLE_DEFAULT);
$fields = $field_list->getFields();
$idx = 0;
foreach ($fields as $field_key => $value) {
if ($key === $field_key) {
return $idx;
}
$idx++;
}
return $idx;
}
public function getFieldTransactions($value) {
return array(
array(
'type' => $this->getCommitMessageFieldKey(),
'value' => $value,
),
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 10, 11:50 PM (23 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
141384
Default Alt Text
(36 KB)

Event Timeline