Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14407647
D17067.id41083.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
29 KB
Referenced Files
None
Subscribers
None
D17067.id41083.diff
View Options
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
@@ -527,6 +527,7 @@
'DifferentialRevisionControlSystem' => 'applications/differential/constants/DifferentialRevisionControlSystem.php',
'DifferentialRevisionDependedOnByRevisionEdgeType' => 'applications/differential/edge/DifferentialRevisionDependedOnByRevisionEdgeType.php',
'DifferentialRevisionDependsOnRevisionEdgeType' => 'applications/differential/edge/DifferentialRevisionDependsOnRevisionEdgeType.php',
+ 'DifferentialRevisionEditConduitAPIMethod' => 'applications/differential/conduit/DifferentialRevisionEditConduitAPIMethod.php',
'DifferentialRevisionEditEngine' => 'applications/differential/editor/DifferentialRevisionEditEngine.php',
'DifferentialRevisionEditProController' => 'applications/differential/controller/DifferentialRevisionEditProController.php',
'DifferentialRevisionFulltextEngine' => 'applications/differential/search/DifferentialRevisionFulltextEngine.php',
@@ -5203,6 +5204,7 @@
'DifferentialRevisionControlSystem' => 'Phobject',
'DifferentialRevisionDependedOnByRevisionEdgeType' => 'PhabricatorEdgeType',
'DifferentialRevisionDependsOnRevisionEdgeType' => 'PhabricatorEdgeType',
+ 'DifferentialRevisionEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'DifferentialRevisionEditEngine' => 'PhabricatorEditEngine',
'DifferentialRevisionEditProController' => 'DifferentialController',
'DifferentialRevisionFulltextEngine' => 'PhabricatorFulltextEngine',
diff --git a/src/applications/differential/conduit/DifferentialConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialConduitAPIMethod.php
--- a/src/applications/differential/conduit/DifferentialConduitAPIMethod.php
+++ b/src/applications/differential/conduit/DifferentialConduitAPIMethod.php
@@ -53,21 +53,16 @@
$viewer = $request->getUser();
- $field_list = PhabricatorCustomField::getObjectFields(
- $revision,
- DifferentialCustomField::ROLE_COMMITMESSAGEEDIT);
-
- $field_list
- ->setViewer($viewer)
- ->readFieldsFromStorage($revision);
- $field_map = mpull($field_list->getFields(), null, 'getFieldKeyForConduit');
+ // We're going to build the body of a "differential.revision.edit" API
+ // request, then just call that code directly.
$xactions = array();
+ $xactions[] = array(
+ 'type' => DifferentialRevisionEditEngine::KEY_UPDATE,
+ 'value' => $diff->getPHID(),
+ );
- $xactions[] = id(new DifferentialTransaction())
- ->setTransactionType(DifferentialTransaction::TYPE_UPDATE)
- ->setNewValue($diff->getPHID());
-
+ $field_map = DifferentialCommitMessageField::newEnabledFields($viewer);
$values = $request->getValue('fields', array());
foreach ($values as $key => $value) {
$field = idx($field_map, $key);
@@ -79,53 +74,20 @@
continue;
}
- $role = PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS;
- if (!$field->shouldEnableForRole($role)) {
- continue;
- }
-
- // TODO: This is fairly similar to PhabricatorCustomField's
- // buildFieldTransactionsFromRequest() method, but that's currently not
- // easy to reuse.
-
- $transaction_type = $field->getApplicationTransactionType();
- $xaction = id(new DifferentialTransaction())
- ->setTransactionType($transaction_type);
-
- if ($transaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) {
- // For TYPE_CUSTOMFIELD transactions only, we provide the old value
- // as an input.
- $old_value = $field->getOldValueForApplicationTransactions();
- $xaction->setOldValue($old_value);
- }
-
// The transaction itself will be validated so this is somewhat
// redundant, but this validator will sometimes give us a better error
// message or a better reaction to a bad value type.
- $field->validateCommitMessageValue($value);
- $field->readValueFromCommitMessage($value);
-
- $xaction
- ->setNewValue($field->getNewValueForApplicationTransactions());
+ $value = $field->readFieldValueFromConduit($value);
- if ($transaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) {
- // For TYPE_CUSTOMFIELD transactions, add the field key in metadata.
- $xaction->setMetadataValue('customfield:key', $field->getFieldKey());
+ foreach ($field->getFieldTransactions($value) as $xaction) {
+ $xactions[] = $xaction;
}
-
- $metadata = $field->getApplicationTransactionMetadata();
- foreach ($metadata as $meta_key => $meta_value) {
- $xaction->setMetadataValue($meta_key, $meta_value);
- }
-
- $xactions[] = $xaction;
}
$message = $request->getValue('message');
if (strlen($message)) {
- // This is a little awkward, and should maybe move inside the transaction
- // editor. It largely exists for legacy reasons. See some discussion in
- // T7899.
+ // This is a little awkward, and should move elsewhere or be removed. It
+ // largely exists for legacy reasons. See some discussion in T7899.
$first_line = head(phutil_split_lines($message, false));
$first_line = id(new PhutilUTF8StringTruncator())
@@ -136,20 +98,24 @@
$diff->setDescription($first_line);
$diff->save();
- $xactions[] = id(new DifferentialTransaction())
- ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
- ->attachComment(
- id(new DifferentialTransactionComment())
- ->setContent($message));
+ $xactions[] = array(
+ 'type' => PhabricatorCommentEditEngineExtension::EDITKEY,
+ 'value' => $message,
+ );
}
- $editor = id(new DifferentialTransactionEditor())
- ->setActor($viewer)
- ->setContentSource($request->newContentSource())
- ->setContinueOnNoEffect(true)
- ->setContinueOnMissingFields(true);
+ $method = 'differential.revision.edit';
+ $params = array(
+ 'transactions' => $xactions,
+ );
+
+ if ($revision->getID()) {
+ $params['objectIdentifier'] = $revision->getID();
+ }
- $editor->applyTransactions($revision, $xactions);
+ return id(new ConduitCall($method, $params, $strict = true))
+ ->setUser($viewer)
+ ->execute();
}
protected function loadCustomFieldsForRevisions(
diff --git a/src/applications/differential/conduit/DifferentialCreateRevisionConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialCreateRevisionConduitAPIMethod.php
--- a/src/applications/differential/conduit/DifferentialCreateRevisionConduitAPIMethod.php
+++ b/src/applications/differential/conduit/DifferentialCreateRevisionConduitAPIMethod.php
@@ -45,16 +45,18 @@
$revision = DifferentialRevision::initializeNewRevision($viewer);
$revision->attachReviewerStatus(array());
- $this->applyFieldEdit(
+ $result = $this->applyFieldEdit(
$request,
$revision,
$diff,
$request->getValue('fields', array()),
$message = null);
+ $revision_id = $result['object']['id'];
+
return array(
- 'revisionid' => $revision->getID(),
- 'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()),
+ 'revisionid' => $revision_id,
+ 'uri' => PhabricatorEnv::getURI('/D'.$revision_id),
);
}
diff --git a/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php
--- a/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php
+++ b/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php
@@ -49,9 +49,15 @@
$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');
- $is_edit = ($edit_mode && !$is_create);
$field_list = DifferentialCommitMessageField::newEnabledFields($viewer);
@@ -62,7 +68,7 @@
// 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_edit) {
+ if ($is_any_edit) {
foreach ($field_list as $field_key => $field) {
if (!$field->isFieldEditable()) {
unset($field_list[$field_key]);
@@ -96,7 +102,7 @@
$wire_value = $value_map[$field_key];
$value = $field->renderFieldValue($wire_value);
- $is_template = ($is_edit && $field->isTemplateField());
+ $is_template = ($is_create && $field->isTemplateField());
if (!is_string($value) && !is_null($value)) {
throw new Exception(
diff --git a/src/applications/differential/conduit/DifferentialRevisionEditConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialRevisionEditConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/conduit/DifferentialRevisionEditConduitAPIMethod.php
@@ -0,0 +1,18 @@
+<?php
+
+final class DifferentialRevisionEditConduitAPIMethod
+ extends PhabricatorEditEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'differential.revision.edit';
+ }
+
+ public function newEditEngine() {
+ return new DifferentialRevisionEditEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht('Apply transactions to create or update a revision.');
+ }
+
+}
diff --git a/src/applications/differential/editor/DifferentialRevisionEditEngine.php b/src/applications/differential/editor/DifferentialRevisionEditEngine.php
--- a/src/applications/differential/editor/DifferentialRevisionEditEngine.php
+++ b/src/applications/differential/editor/DifferentialRevisionEditEngine.php
@@ -7,6 +7,8 @@
const ENGINECONST = 'differential.revision';
+ const KEY_UPDATE = 'update';
+
public function getEngineName() {
return pht('Revisions');
}
@@ -100,21 +102,20 @@
$fields = array();
- if ($diff || $is_create) {
- $fields[] = id(new PhabricatorHandlesEditField())
- ->setKey('update')
- ->setLabel(pht('Update Diff'))
- ->setDescription(pht('New diff to create or update the revision with.'))
- ->setConduitDescription(pht('Create or update a revision with a diff.'))
- ->setConduitTypeDescription(pht('PHID of the diff.'))
- ->setTransactionType(DifferentialTransaction::TYPE_UPDATE)
- ->setHandleParameterType(new AphrontPHIDListHTTPParameterType())
- ->setSingleValue($diff_phid)
- ->setIsReorderable(false)
- ->setIsDefaultable(false)
- ->setIsInvisible(true)
- ->setIsLockable(false);
- }
+ $fields[] = id(new PhabricatorHandlesEditField())
+ ->setKey(self::KEY_UPDATE)
+ ->setLabel(pht('Update Diff'))
+ ->setDescription(pht('New diff to create or update the revision with.'))
+ ->setConduitDescription(pht('Create or update a revision with a diff.'))
+ ->setConduitTypeDescription(pht('PHID of the diff.'))
+ ->setTransactionType(DifferentialTransaction::TYPE_UPDATE)
+ ->setHandleParameterType(new AphrontPHIDListHTTPParameterType())
+ ->setSingleValue($diff_phid)
+ ->setIsConduitOnly(!$diff)
+ ->setIsReorderable(false)
+ ->setIsDefaultable(false)
+ ->setIsInvisible(true)
+ ->setIsLockable(false);
if ($is_update) {
$fields[] = id(new PhabricatorInstructionsEditField())
@@ -134,7 +135,7 @@
}
$fields[] = id(new PhabricatorTextEditField())
- ->setKey('title')
+ ->setKey(DifferentialRevisionTitleTransaction::EDITKEY)
->setLabel(pht('Title'))
->setIsRequired(true)
->setTransactionType(
@@ -145,7 +146,7 @@
->setValue($object->getTitle());
$fields[] = id(new PhabricatorRemarkupEditField())
- ->setKey('summary')
+ ->setKey(DifferentialRevisionSummaryTransaction::EDITKEY)
->setLabel(pht('Summary'))
->setTransactionType(
DifferentialRevisionSummaryTransaction::TRANSACTIONTYPE)
@@ -156,7 +157,7 @@
if ($plan_enabled) {
$fields[] = id(new PhabricatorRemarkupEditField())
- ->setKey('testPlan')
+ ->setKey(DifferentialRevisionTestPlanTransaction::EDITKEY)
->setLabel(pht('Test Plan'))
->setIsRequired($plan_required)
->setTransactionType(
@@ -169,7 +170,7 @@
}
$fields[] = id(new PhabricatorDatasourceEditField())
- ->setKey('reviewerPHIDs')
+ ->setKey(DifferentialRevisionReviewersTransaction::EDITKEY)
->setLabel(pht('Reviewers'))
->setDatasource(new DifferentialReviewerDatasource())
->setUseEdgeTransactions(true)
diff --git a/src/applications/differential/field/DifferentialCommitMessageCustomField.php b/src/applications/differential/field/DifferentialCommitMessageCustomField.php
--- a/src/applications/differential/field/DifferentialCommitMessageCustomField.php
+++ b/src/applications/differential/field/DifferentialCommitMessageCustomField.php
@@ -60,4 +60,9 @@
return $idx;
}
+ public function getFieldTransactions($value) {
+ // TODO: Implement this!
+ return array();
+ }
+
}
diff --git a/src/applications/differential/field/DifferentialCommitMessageField.php b/src/applications/differential/field/DifferentialCommitMessageField.php
--- a/src/applications/differential/field/DifferentialCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialCommitMessageField.php
@@ -67,6 +67,13 @@
return $value;
}
+ public function getFieldTransactions($value) {
+ if (!$this->isFieldEditable()) {
+ return array();
+ }
+ throw new PhutilMethodNotImplementedException();
+ }
+
final public function getCommitMessageFieldKey() {
return $this->getPhobjectClassConstant('FIELDKEY', 64);
}
diff --git a/src/applications/differential/field/DifferentialConflictsCommitMessageField.php b/src/applications/differential/field/DifferentialConflictsCommitMessageField.php
--- a/src/applications/differential/field/DifferentialConflictsCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialConflictsCommitMessageField.php
@@ -17,4 +17,8 @@
return false;
}
+ public function isTemplateField() {
+ return false;
+ }
+
}
diff --git a/src/applications/differential/field/DifferentialGitSVNIDCommitMessageField.php b/src/applications/differential/field/DifferentialGitSVNIDCommitMessageField.php
--- a/src/applications/differential/field/DifferentialGitSVNIDCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialGitSVNIDCommitMessageField.php
@@ -17,4 +17,8 @@
return false;
}
+ public function isTemplateField() {
+ return false;
+ }
+
}
diff --git a/src/applications/differential/field/DifferentialReviewedByCommitMessageField.php b/src/applications/differential/field/DifferentialReviewedByCommitMessageField.php
--- a/src/applications/differential/field/DifferentialReviewedByCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialReviewedByCommitMessageField.php
@@ -27,6 +27,10 @@
return false;
}
+ public function isTemplateField() {
+ return false;
+ }
+
public function readFieldValueFromObject(DifferentialRevision $revision) {
if (!$revision->getPHID()) {
return array();
diff --git a/src/applications/differential/field/DifferentialReviewersCommitMessageField.php b/src/applications/differential/field/DifferentialReviewersCommitMessageField.php
--- a/src/applications/differential/field/DifferentialReviewersCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialReviewersCommitMessageField.php
@@ -77,6 +77,30 @@
return $this->renderHandleList($phid_list, $suffix_map);
}
+ public function getFieldTransactions($value) {
+ $value = $this->inflateReviewers($value);
+
+ $reviewer_list = array();
+ foreach ($value as $reviewer) {
+ $phid = $reviewer['phid'];
+ if (isset($reviewer['suffixes']['!'])) {
+ $reviewer_list[] = 'blocking('.$phid.')';
+ } else {
+ $reviewer_list[] = $phid;
+ }
+ }
+
+ $xaction_key = DifferentialRevisionReviewersTransaction::EDITKEY;
+ $xaction_type = "{$xaction_key}.set";
+
+ return array(
+ array(
+ 'type' => $xaction_type,
+ 'value' => $reviewer_list,
+ ),
+ );
+ }
+
private function flattenReviewers(array $values) {
// NOTE: For now, `arc` relies on this field returning only scalars, so we
// need to reduce the results into scalars. See T10981.
diff --git a/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php b/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
--- a/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
@@ -76,4 +76,8 @@
return PhabricatorEnv::getProductionURI('/D'.$value);
}
+ public function getFieldTransactions($value) {
+ return array();
+ }
+
}
diff --git a/src/applications/differential/field/DifferentialSubscribersCommitMessageField.php b/src/applications/differential/field/DifferentialSubscribersCommitMessageField.php
--- a/src/applications/differential/field/DifferentialSubscribersCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialSubscribersCommitMessageField.php
@@ -48,4 +48,13 @@
return $this->renderHandleList($value);
}
+ public function getFieldTransactions($value) {
+ return array(
+ array(
+ 'type' => PhabricatorSubscriptionsEditEngineExtension::EDITKEY_SET,
+ 'value' => $value,
+ ),
+ );
+ }
+
}
diff --git a/src/applications/differential/field/DifferentialSummaryCommitMessageField.php b/src/applications/differential/field/DifferentialSummaryCommitMessageField.php
--- a/src/applications/differential/field/DifferentialSummaryCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialSummaryCommitMessageField.php
@@ -17,4 +17,13 @@
return $revision->getSummary();
}
+ public function getFieldTransactions($value) {
+ return array(
+ array(
+ 'type' => DifferentialRevisionSummaryTransaction::EDITKEY,
+ 'value' => $value,
+ ),
+ );
+ }
+
}
diff --git a/src/applications/differential/field/DifferentialTagsCommitMessageField.php b/src/applications/differential/field/DifferentialTagsCommitMessageField.php
--- a/src/applications/differential/field/DifferentialTagsCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialTagsCommitMessageField.php
@@ -54,5 +54,13 @@
return $this->renderHandleList($value);
}
+ public function getFieldTransactions($value) {
+ return array(
+ array(
+ 'type' => PhabricatorProjectsEditEngineExtension::EDITKEY_SET,
+ 'value' => $value,
+ ),
+ );
+ }
}
diff --git a/src/applications/differential/field/DifferentialTasksCommitMessageField.php b/src/applications/differential/field/DifferentialTasksCommitMessageField.php
--- a/src/applications/differential/field/DifferentialTasksCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialTasksCommitMessageField.php
@@ -54,4 +54,8 @@
return $this->renderHandleList($value);
}
+ public function getFieldTransactions($value) {
+ // TODO: Implement this!
+ return array();
+ }
}
diff --git a/src/applications/differential/field/DifferentialTestPlanCommitMessageField.php b/src/applications/differential/field/DifferentialTestPlanCommitMessageField.php
--- a/src/applications/differential/field/DifferentialTestPlanCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialTestPlanCommitMessageField.php
@@ -41,4 +41,13 @@
return $revision->getTestPlan();
}
+ public function getFieldTransactions($value) {
+ return array(
+ array(
+ 'type' => DifferentialRevisionTestPlanTransaction::EDITKEY,
+ 'value' => $value,
+ ),
+ );
+ }
+
}
diff --git a/src/applications/differential/field/DifferentialTitleCommitMessageField.php b/src/applications/differential/field/DifferentialTitleCommitMessageField.php
--- a/src/applications/differential/field/DifferentialTitleCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialTitleCommitMessageField.php
@@ -47,4 +47,13 @@
return $value;
}
+ public function getFieldTransactions($value) {
+ return array(
+ array(
+ 'type' => DifferentialRevisionTitleTransaction::EDITKEY,
+ 'value' => $value,
+ ),
+ );
+ }
+
}
diff --git a/src/applications/differential/xaction/DifferentialRevisionReviewersTransaction.php b/src/applications/differential/xaction/DifferentialRevisionReviewersTransaction.php
--- a/src/applications/differential/xaction/DifferentialRevisionReviewersTransaction.php
+++ b/src/applications/differential/xaction/DifferentialRevisionReviewersTransaction.php
@@ -4,6 +4,7 @@
extends DifferentialRevisionTransactionType {
const TRANSACTIONTYPE = 'differential.revision.reviewers';
+ const EDITKEY = 'reviewers';
public function generateOldValue($object) {
$reviewers = $object->getReviewerStatus();
@@ -18,6 +19,7 @@
->setViewer($actor);
$reviewers = $this->generateOldValue($object);
+ $old_reviewers = $reviewers;
// First, remove any reviewers we're getting rid of.
$rem = idx($value, '-', array());
@@ -63,7 +65,7 @@
$status_blocking = DifferentialReviewerStatus::STATUS_BLOCKING;
foreach ($add_map as $phid => $new_status) {
- $old_status = idx($reviewers, $phid);
+ $old_status = idx($old_reviewers, $phid);
// If we have an old status and this didn't make the reviewer blocking
// or nonblocking, just retain the old status. This makes sure we don't
@@ -76,6 +78,7 @@
$is_unblock = (!$now_blocking && $was_blocking);
if (!$is_block && !$is_unblock) {
+ $reviewers[$phid] = $old_status;
continue;
}
}
@@ -86,6 +89,14 @@
return $reviewers;
}
+ public function getTransactionHasEffect($object, $old, $new) {
+ // At least for now, we ignore transactions which ONLY reorder reviewers
+ // without making any actual changes.
+ ksort($old);
+ ksort($new);
+ return ($old !== $new);
+ }
+
public function applyExternalEffects($object, $value) {
$src_phid = $object->getPHID();
diff --git a/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php b/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php
--- a/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php
+++ b/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php
@@ -4,6 +4,7 @@
extends DifferentialRevisionTransactionType {
const TRANSACTIONTYPE = 'differential.revision.summary';
+ const EDITKEY = 'summary';
public function generateOldValue($object) {
return $object->getSummary();
diff --git a/src/applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php b/src/applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php
--- a/src/applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php
+++ b/src/applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php
@@ -4,6 +4,7 @@
extends DifferentialRevisionTransactionType {
const TRANSACTIONTYPE = 'differential.revision.testplan';
+ const EDITKEY = 'testPlan';
public function generateOldValue($object) {
return $object->getTestPlan();
diff --git a/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php b/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php
--- a/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php
+++ b/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php
@@ -4,6 +4,7 @@
extends DifferentialRevisionTransactionType {
const TRANSACTIONTYPE = 'differential.revision.title';
+ const EDITKEY = 'title';
public function generateOldValue($object) {
return $object->getTitle();
diff --git a/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php b/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php
--- a/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php
+++ b/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php
@@ -5,6 +5,10 @@
const EXTENSIONKEY = 'projects.projects';
+ const EDITKEY_ADD = 'projects.add';
+ const EDITKEY_SET = 'projects.set';
+ const EDITKEY_REMOVE = 'projects.remove';
+
public function getExtensionPriority() {
return 500;
}
@@ -58,14 +62,14 @@
$projects_field->setViewer($engine->getViewer());
- $edit_add = $projects_field->getConduitEditType('projects.add')
+ $edit_add = $projects_field->getConduitEditType(self::EDITKEY_ADD)
->setConduitDescription(pht('Add project tags.'));
- $edit_set = $projects_field->getConduitEditType('projects.set')
+ $edit_set = $projects_field->getConduitEditType(self::EDITKEY_SET)
->setConduitDescription(
pht('Set project tags, overwriting current value.'));
- $edit_rem = $projects_field->getConduitEditType('projects.remove')
+ $edit_rem = $projects_field->getConduitEditType(self::EDITKEY_REMOVE)
->setConduitDescription(pht('Remove project tags.'));
return array(
diff --git a/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php b/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php
--- a/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php
+++ b/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php
@@ -5,6 +5,10 @@
const EXTENSIONKEY = 'subscriptions.subscribers';
+ const EDITKEY_ADD = 'subscribers.add';
+ const EDITKEY_SET = 'subscribers.set';
+ const EDITKEY_REMOVE = 'subscribers.remove';
+
public function getExtensionPriority() {
return 750;
}
@@ -52,14 +56,14 @@
$subscribers_field->setViewer($engine->getViewer());
- $edit_add = $subscribers_field->getConduitEditType('subscribers.add')
+ $edit_add = $subscribers_field->getConduitEditType(self::EDITKEY_ADD)
->setConduitDescription(pht('Add subscribers.'));
- $edit_set = $subscribers_field->getConduitEditType('subscribers.set')
+ $edit_set = $subscribers_field->getConduitEditType(self::EDITKEY_SET)
->setConduitDescription(
pht('Set subscribers, overwriting current value.'));
- $edit_rem = $subscribers_field->getConduitEditType('subscribers.remove')
+ $edit_rem = $subscribers_field->getConduitEditType(self::EDITKEY_REMOVE)
->setConduitDescription(pht('Remove subscribers.'));
return array(
diff --git a/src/applications/transactions/engineextension/PhabricatorCommentEditEngineExtension.php b/src/applications/transactions/engineextension/PhabricatorCommentEditEngineExtension.php
--- a/src/applications/transactions/engineextension/PhabricatorCommentEditEngineExtension.php
+++ b/src/applications/transactions/engineextension/PhabricatorCommentEditEngineExtension.php
@@ -4,6 +4,7 @@
extends PhabricatorEditEngineExtension {
const EXTENSIONKEY = 'transactions.comment';
+ const EDITKEY = 'comment';
public function getExtensionPriority() {
return 9000;
@@ -39,7 +40,7 @@
$comment_type = PhabricatorTransactions::TYPE_COMMENT;
$comment_field = id(new PhabricatorCommentEditField())
- ->setKey('comment')
+ ->setKey(self::EDITKEY)
->setLabel(pht('Comments'))
->setAliases(array('comments'))
->setIsHidden(true)
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
+++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
@@ -396,13 +396,16 @@
if (!self::isFunctionToken($token)) {
$results[] = $token;
} else {
- $evaluate[] = $token;
+ // Put a placeholder in the result list so that we retain token order
+ // when possible. We'll overwrite this below.
+ $results[] = null;
+ $evaluate[last_key($results)] = $token;
}
}
$results = $this->evaluateValues($results);
- foreach ($evaluate as $function) {
+ foreach ($evaluate as $result_key => $function) {
$function = self::parseFunction($function);
if (!$function) {
throw new PhabricatorTypeaheadInvalidTokenException();
@@ -411,11 +414,23 @@
$name = $function['name'];
$argv = $function['argv'];
- foreach ($this->evaluateFunction($name, array($argv)) as $phid) {
- $results[] = $phid;
+ $evaluated_tokens = $this->evaluateFunction($name, array($argv));
+ if (!$evaluated_tokens) {
+ unset($results[$result_key]);
+ } else {
+ $is_first = true;
+ foreach ($evaluated_tokens as $phid) {
+ if ($is_first) {
+ $results[$result_key] = $phid;
+ $is_first = false;
+ } else {
+ $results[] = $phid;
+ }
+ }
}
}
+ $results = array_values($results);
$results = $this->didEvaluateTokens($results);
return $results;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 3:24 AM (7 h, 18 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6924709
Default Alt Text
D17067.id41083.diff (29 KB)
Attached To
Mode
D17067: Drive CLI-based revision edits through "differential.revision.edit" API + EditEngine
Attached
Detach File
Event Timeline
Log In to Comment