Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13982220
D17047.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D17047.id.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
@@ -545,6 +545,7 @@
'DifferentialRevisionRelationshipSource' => 'applications/search/relationship/DifferentialRevisionRelationshipSource.php',
'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php',
'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php',
+ 'DifferentialRevisionRepositoryTransaction' => 'applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php',
'DifferentialRevisionRequiredActionResultBucket' => 'applications/differential/query/DifferentialRevisionRequiredActionResultBucket.php',
'DifferentialRevisionResultBucket' => 'applications/differential/query/DifferentialRevisionResultBucket.php',
'DifferentialRevisionReviewersHeraldField' => 'applications/differential/herald/DifferentialRevisionReviewersHeraldField.php',
@@ -552,6 +553,7 @@
'DifferentialRevisionSearchEngine' => 'applications/differential/query/DifferentialRevisionSearchEngine.php',
'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php',
'DifferentialRevisionSummaryHeraldField' => 'applications/differential/herald/DifferentialRevisionSummaryHeraldField.php',
+ 'DifferentialRevisionSummaryTransaction' => 'applications/differential/xaction/DifferentialRevisionSummaryTransaction.php',
'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php',
'DifferentialRevisionTitleTransaction' => 'applications/differential/xaction/DifferentialRevisionTitleTransaction.php',
'DifferentialRevisionTransactionType' => 'applications/differential/xaction/DifferentialRevisionTransactionType.php',
@@ -5195,6 +5197,7 @@
'DifferentialRevisionRelationshipSource' => 'PhabricatorObjectRelationshipSource',
'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField',
+ 'DifferentialRevisionRepositoryTransaction' => 'DifferentialRevisionTransactionType',
'DifferentialRevisionRequiredActionResultBucket' => 'DifferentialRevisionResultBucket',
'DifferentialRevisionResultBucket' => 'PhabricatorSearchResultBucket',
'DifferentialRevisionReviewersHeraldField' => 'DifferentialRevisionHeraldField',
@@ -5202,6 +5205,7 @@
'DifferentialRevisionSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DifferentialRevisionStatus' => 'Phobject',
'DifferentialRevisionSummaryHeraldField' => 'DifferentialRevisionHeraldField',
+ 'DifferentialRevisionSummaryTransaction' => 'DifferentialRevisionTransactionType',
'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionTitleTransaction' => 'DifferentialRevisionTransactionType',
'DifferentialRevisionTransactionType' => 'PhabricatorModularTransactionType',
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
@@ -64,12 +64,32 @@
id(new PhabricatorTextEditField())
->setKey('title')
->setLabel(pht('Title'))
+ ->setIsRequired(true)
->setTransactionType(
DifferentialRevisionTitleTransaction::TRANSACTIONTYPE)
->setDescription(pht('The title of the revision.'))
->setConduitDescription(pht('Retitle the revision.'))
->setConduitTypeDescription(pht('New revision title.'))
->setValue($object->getTitle()),
+ id(new PhabricatorRemarkupEditField())
+ ->setKey('summary')
+ ->setLabel(pht('Summary'))
+ ->setTransactionType(
+ DifferentialRevisionSummaryTransaction::TRANSACTIONTYPE)
+ ->setDescription(pht('The summary of the revision.'))
+ ->setConduitDescription(pht('Change the revision summary.'))
+ ->setConduitTypeDescription(pht('New revision summary.'))
+ ->setValue($object->getSummary()),
+ id(new PhabricatorDatasourceEditField())
+ ->setKey('repositoryPHID')
+ ->setLabel(pht('Repository'))
+ ->setDatasource(new DiffusionRepositoryDatasource())
+ ->setTransactionType(
+ DifferentialRevisionRepositoryTransaction::TRANSACTIONTYPE)
+ ->setDescription(pht('The repository the revision belongs to.'))
+ ->setConduitDescription(pht('Change the repository for this revision.'))
+ ->setConduitTypeDescription(pht('New repository.'))
+ ->setSingleValue($object->getRepositoryPHID()),
);
}
diff --git a/src/applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php b/src/applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/xaction/DifferentialRevisionRepositoryTransaction.php
@@ -0,0 +1,95 @@
+<?php
+
+final class DifferentialRevisionRepositoryTransaction
+ extends DifferentialRevisionTransactionType {
+
+ const TRANSACTIONTYPE = 'differential.revision.repository';
+
+ public function generateOldValue($object) {
+ return $object->getRepositoryPHID();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setRepositoryPHID($value);
+ }
+
+ public function getTitle() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+ if ($old && $new) {
+ return pht(
+ '%s changed the repository for this revision from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderHandle($old),
+ $this->renderHandle($new));
+ } else if ($new) {
+ return pht(
+ '%s set the repository for this revision to %s.',
+ $this->renderAuthor(),
+ $this->renderHandle($new));
+ } else {
+ return pht(
+ '%s removed %s as the repository for this revision.',
+ $this->renderAuthor(),
+ $this->renderHandle($old));
+ }
+ }
+
+ public function getTitleForFeed() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+ if ($old && $new) {
+ return pht(
+ '%s changed the repository for %s from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderHandle($old),
+ $this->renderHandle($new));
+ } else if ($new) {
+ return pht(
+ '%s set the repository for %s to %s.',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderHandle($new));
+ } else {
+ return pht(
+ '%s removed %s as the repository for %s.',
+ $this->renderAuthor(),
+ $this->renderHandle($old),
+ $this->renderObject());
+ }
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ $actor = $this->getActor();
+
+ $errors = array();
+
+ $old_value = $object->getRepositoryPHID();
+ foreach ($xactions as $xaction) {
+ $new_value = $xaction->getNewValue();
+ if (!$new_value) {
+ continue;
+ }
+
+ if ($new_value == $old_value) {
+ continue;
+ }
+
+ $repository = id(new PhabricatorRepositoryQuery())
+ ->setViewer($actor)
+ ->withPHIDs(array($new_value))
+ ->executeOne();
+ if (!$repository) {
+ $errors[] = $this->newInvalidError(
+ pht(
+ 'Repository "%s" is not a valid repository, or you do not have '.
+ 'permission to view it.'),
+ $xaction);
+ }
+ }
+
+ return $errors;
+ }
+
+}
diff --git a/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php b/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/xaction/DifferentialRevisionSummaryTransaction.php
@@ -0,0 +1,56 @@
+<?php
+
+final class DifferentialRevisionSummaryTransaction
+ extends DifferentialRevisionTransactionType {
+
+ const TRANSACTIONTYPE = 'differential.revision.summary';
+
+ public function generateOldValue($object) {
+ return $object->getSummary();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setSummary($value);
+ }
+
+ public function getTitle() {
+ return pht(
+ '%s edited the summary of this revision.',
+ $this->renderAuthor());
+ }
+
+ public function getTitleForFeed() {
+ return pht(
+ '%s updated the summary of %s.',
+ $this->renderAuthor(),
+ $this->renderObject());
+ }
+
+ public function hasChangeDetailView() {
+ return true;
+ }
+
+ public function getMailDiffSectionHeader() {
+ return pht('CHANGES TO REVISION SUMMARY');
+ }
+
+ public function newChangeDetailView() {
+ $viewer = $this->getViewer();
+
+ return id(new PhabricatorApplicationTransactionTextDiffDetailView())
+ ->setViewer($viewer)
+ ->setOldText($this->getOldValue())
+ ->setNewText($this->getNewValue());
+ }
+
+ public function newRemarkupChanges() {
+ $changes = array();
+
+ $changes[] = $this->newRemarkupChange()
+ ->setOldValue($this->getOldValue())
+ ->setNewValue($this->getNewValue());
+
+ return $changes;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 20, 9:55 PM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6737495
Default Alt Text
D17047.id.diff (9 KB)
Attached To
Mode
D17047: Add Summary and Repository EditEngine fields + Modular Transactions to Differential
Attached
Detach File
Event Timeline
Log In to Comment