Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14004153
D17044.id41007.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D17044.id41007.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
@@ -553,6 +553,8 @@
'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php',
'DifferentialRevisionSummaryHeraldField' => 'applications/differential/herald/DifferentialRevisionSummaryHeraldField.php',
'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php',
+ 'DifferentialRevisionTitleTransaction' => 'applications/differential/xaction/DifferentialRevisionTitleTransaction.php',
+ 'DifferentialRevisionTransactionType' => 'applications/differential/xaction/DifferentialRevisionTransactionType.php',
'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/DifferentialRevisionUpdateHistoryView.php',
'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php',
'DifferentialSchemaSpec' => 'applications/differential/storage/DifferentialSchemaSpec.php',
@@ -5201,6 +5203,8 @@
'DifferentialRevisionStatus' => 'Phobject',
'DifferentialRevisionSummaryHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField',
+ 'DifferentialRevisionTitleTransaction' => 'DifferentialRevisionTransactionType',
+ 'DifferentialRevisionTransactionType' => 'PhabricatorModularTransactionType',
'DifferentialRevisionUpdateHistoryView' => 'AphrontView',
'DifferentialRevisionViewController' => 'DifferentialController',
'DifferentialSchemaSpec' => 'PhabricatorConfigSchemaSpec',
@@ -5210,7 +5214,7 @@
'DifferentialSummaryField' => 'DifferentialCoreCustomField',
'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
'DifferentialTitleField' => 'DifferentialCoreCustomField',
- 'DifferentialTransaction' => 'PhabricatorApplicationTransaction',
+ 'DifferentialTransaction' => 'PhabricatorModularTransaction',
'DifferentialTransactionComment' => 'PhabricatorApplicationTransactionComment',
'DifferentialTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
'DifferentialTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
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
@@ -60,7 +60,17 @@
}
protected function buildCustomEditFields($object) {
- return array();
+ return array(
+ id(new PhabricatorTextEditField())
+ ->setKey('title')
+ ->setLabel(pht('Title'))
+ ->setTransactionType(
+ DifferentialRevisionTitleTransaction::TRANSACTIONTYPE)
+ ->setDescription(pht('The title of the revision.'))
+ ->setConduitDescription(pht('Retitle the revision.'))
+ ->setConduitTypeDescription(pht('New revision title.'))
+ ->setValue($object->getTitle()),
+ );
}
}
diff --git a/src/applications/differential/storage/DifferentialTransaction.php b/src/applications/differential/storage/DifferentialTransaction.php
--- a/src/applications/differential/storage/DifferentialTransaction.php
+++ b/src/applications/differential/storage/DifferentialTransaction.php
@@ -1,6 +1,7 @@
<?php
-final class DifferentialTransaction extends PhabricatorApplicationTransaction {
+final class DifferentialTransaction
+ extends PhabricatorModularTransaction {
private $isCommandeerSideEffect;
@@ -17,6 +18,9 @@
const MAILTAG_REVIEW_REQUEST = 'differential-review-request';
const MAILTAG_OTHER = 'differential-other';
+ public function getBaseTransactionClass() {
+ return 'DifferentialRevisionTransactionType';
+ }
public function setIsCommandeerSideEffect($is_side_effect) {
$this->isCommandeerSideEffect = $is_side_effect;
diff --git a/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php b/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php
@@ -0,0 +1,57 @@
+<?php
+
+final class DifferentialRevisionTitleTransaction
+ extends DifferentialRevisionTransactionType {
+
+ const TRANSACTIONTYPE = 'differential.revision.title';
+
+ public function generateOldValue($object) {
+ return $object->getTitle();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setTitle($value);
+ }
+
+ public function getTitle() {
+ return pht(
+ '%s retitled this revision from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderOldValue(),
+ $this->renderNewValue());
+ }
+
+ public function getTitleForFeed() {
+ return pht(
+ '%s retitled %s from %s to %s.',
+ $this->renderAuthor(),
+ $this->renderObject(),
+ $this->renderOldValue(),
+ $this->renderNewValue());
+ }
+
+ public function validateTransactions($object, array $xactions) {
+ $errors = array();
+
+ if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {
+ $errors[] = $this->newRequiredError(
+ pht('Revisions must have a title.'));
+ }
+
+ $max_length = $object->getColumnMaximumByteLength('title');
+ foreach ($xactions as $xaction) {
+ $new_value = $xaction->getNewValue();
+ $new_length = strlen($new_value);
+ if ($new_length > $max_length) {
+ $errors[] = $this->newInvalidError(
+ pht(
+ 'Revision title is too long: the maximum length of a '.
+ 'revision title is 255 bytes.'),
+ $xaction);
+ }
+ }
+
+ return $errors;
+ }
+
+}
diff --git a/src/applications/differential/xaction/DifferentialRevisionTransactionType.php b/src/applications/differential/xaction/DifferentialRevisionTransactionType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/xaction/DifferentialRevisionTransactionType.php
@@ -0,0 +1,4 @@
+<?php
+
+abstract class DifferentialRevisionTransactionType
+ extends PhabricatorModularTransactionType {}
diff --git a/src/applications/transactions/storage/PhabricatorModularTransaction.php b/src/applications/transactions/storage/PhabricatorModularTransaction.php
--- a/src/applications/transactions/storage/PhabricatorModularTransaction.php
+++ b/src/applications/transactions/storage/PhabricatorModularTransaction.php
@@ -1,5 +1,9 @@
<?php
+// TODO: Some "final" modifiers have been VERY TEMPORARILY moved aside to
+// allow DifferentialTransaction to extend this class without converting
+// fully to ModularTransactions.
+
abstract class PhabricatorModularTransaction
extends PhabricatorApplicationTransaction {
@@ -76,7 +80,7 @@
->applyExternalEffects($object);
}
- final public function shouldHide() {
+ /* final */ public function shouldHide() {
if ($this->getTransactionImplementation()->shouldHide()) {
return true;
}
@@ -84,7 +88,7 @@
return parent::shouldHide();
}
- final public function getIcon() {
+ /* final */ public function getIcon() {
$icon = $this->getTransactionImplementation()->getIcon();
if ($icon !== null) {
return $icon;
@@ -93,7 +97,7 @@
return parent::getIcon();
}
- final public function getTitle() {
+ /* final */ public function getTitle() {
$title = $this->getTransactionImplementation()->getTitle();
if ($title !== null) {
return $title;
@@ -111,7 +115,7 @@
return $title;
}
- final public function getTitleForFeed() {
+ /* final */ public function getTitleForFeed() {
$title = $this->getTransactionImplementation()->getTitleForFeed();
if ($title !== null) {
return $title;
@@ -120,7 +124,7 @@
return parent::getTitleForFeed();
}
- final public function getColor() {
+ /* final */ public function getColor() {
$color = $this->getTransactionImplementation()->getColor();
if ($color !== null) {
return $color;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 27, 4:24 PM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6738410
Default Alt Text
D17044.id41007.diff (8 KB)
Attached To
Mode
D17044: Begin adding "pro" modular transaction fields to Differential
Attached
Detach File
Event Timeline
Log In to Comment