Page MenuHomePhabricator

D12823.id32447.diff
No OneTemporary

D12823.id32447.diff

diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php
--- a/src/applications/differential/editor/DifferentialTransactionEditor.php
+++ b/src/applications/differential/editor/DifferentialTransactionEditor.php
@@ -62,6 +62,7 @@
$types[] = DifferentialTransaction::TYPE_INLINE;
$types[] = DifferentialTransaction::TYPE_STATUS;
$types[] = DifferentialTransaction::TYPE_UPDATE;
+ $types[] = DifferentialTransaction::TYPE_UNBLOCK;
return $types;
}
@@ -72,8 +73,8 @@
switch ($xaction->getTransactionType()) {
case DifferentialTransaction::TYPE_ACTION:
- return null;
case DifferentialTransaction::TYPE_INLINE:
+ case DifferentialTransaction::TYPE_UNBLOCK:
return null;
case DifferentialTransaction::TYPE_UPDATE:
if ($this->getIsNewObject()) {
@@ -93,6 +94,7 @@
switch ($xaction->getTransactionType()) {
case DifferentialTransaction::TYPE_ACTION:
case DifferentialTransaction::TYPE_UPDATE:
+ case DifferentialTransaction::TYPE_UNBLOCK:
return $xaction->getNewValue();
case DifferentialTransaction::TYPE_INLINE:
return null;
@@ -184,6 +186,7 @@
switch ($xaction->getTransactionType()) {
case DifferentialTransaction::TYPE_INLINE:
+ case DifferentialTransaction::TYPE_UNBLOCK:
return;
case DifferentialTransaction::TYPE_UPDATE:
if (!$this->getIsCloseByCommit()) {
@@ -562,6 +565,7 @@
switch ($xaction->getTransactionType()) {
case DifferentialTransaction::TYPE_ACTION:
+ case DifferentialTransaction::TYPE_UNBLOCK:
return;
case DifferentialTransaction::TYPE_INLINE:
$reply = $xaction->getComment()->getReplyToComment();
@@ -758,6 +762,59 @@
break;
}
+ // When we change the status of a revision, update revisions this revision
+ // blocks with a message to the effect of "alincoln closed blocking
+ // revision Dxxx."
+ $unblock_xaction = null;
+ foreach ($xactions as $xaction) {
+ switch ($xaction->getTransactionType()) {
+ case DifferentialTransaction::TYPE_ACTION:
+ switch ($xaction->getNewValue()) {
+ case DifferentialAction::ACTION_CLOSE:
+ case DifferentialAction::ACTION_REOPEN:
+ $unblock_xaction = $xaction;
+ break;
+ }
+ break;
+ }
+ }
+
+ if ($unblock_xaction !== null) {
+ $blocked_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $object->getPHID(),
+ DifferentialRevisionDependedOnByRevisionEdgeType::EDGECONST);
+ if ($blocked_phids) {
+ // In theory we could apply these through policies, but that seems a
+ // little bit surprising. For now, use the actor's vision.
+ $blocked_revisions = id(new DifferentialRevisionQuery())
+ ->setViewer($this->getActor())
+ ->withPHIDs($blocked_phids)
+ // ->needSubscriberPHIDs(true)
+ // ->needProjectPHIDs(true)
+ ->execute();
+
+ $old = $unblock_xaction->getOldValue();
+ $new = $unblock_xaction->getNewValue();
+
+ foreach ($blocked_revisions as $blocked_revision) {
+ $unblock_xactions = array();
+
+ $unblock_xactions[] = id(new DifferentialTransaction())
+ ->setTransactionType(DifferentialTransaction::TYPE_UNBLOCK)
+ ->setOldValue(array($object->getPHID() => $old))
+ ->setNewValue(array($object->getPHID() => $new));
+
+ id(new DifferentialTransactionEditor())
+ ->setActor($this->getActor())
+ ->setActingAsPHID($this->getActingAsPHID())
+ ->setContentSource($this->getContentSource())
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($blocked_revision, $unblock_xactions);
+ }
+ }
+ }
+
return $xactions;
}
@@ -1262,6 +1319,8 @@
pht('A revision is created.'),
DifferentialTransaction::MAILTAG_UPDATED =>
pht('A revision is updated.'),
+ DifferentialTransaction::MAILTAG_UNBLOCK =>
+ pht('One of the revisions a revision is blocked by changes status.'),
DifferentialTransaction::MAILTAG_COMMENT =>
pht('Someone comments on a revision.'),
DifferentialTransaction::MAILTAG_CLOSED =>
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
@@ -8,6 +8,7 @@
const TYPE_UPDATE = 'differential:update';
const TYPE_ACTION = 'differential:action';
const TYPE_STATUS = 'differential:status';
+ const TYPE_UNBLOCK = 'differential:unblock';
const MAILTAG_REVIEWERS = 'differential-reviewers';
const MAILTAG_CLOSED = 'differential-committed';
@@ -15,6 +16,7 @@
const MAILTAG_COMMENT = 'differential-comment';
const MAILTAG_UPDATED = 'differential-updated';
const MAILTAG_REVIEW_REQUEST = 'differential-review-request';
+ const MAILTAG_UNBLOCK = 'differential-unblock';
const MAILTAG_OTHER = 'differential-other';
@@ -43,6 +45,15 @@
return new DifferentialTransactionView();
}
+ public function shouldGenerateOldValue() {
+ switch ($this->getTransactionType()) {
+ case self::TYPE_UNBLOCK:
+ return false;
+ }
+
+ return parent::shouldGenerateOldValue();
+ }
+
public function shouldHide() {
$old = $this->getOldValue();
$new = $this->getNewValue();
@@ -111,6 +122,11 @@
$phids[] = $new;
}
break;
+ case self::TYPE_UNBLOCK:
+ foreach (array_keys($new) as $phid) {
+ $phids[] = $phid;
+ }
+ break;
}
return $phids;
@@ -129,11 +145,13 @@
public function getActionName() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
switch ($this->getTransactionType()) {
case self::TYPE_INLINE:
return pht('Commented On');
case self::TYPE_UPDATE:
- $old = $this->getOldValue();
if ($old === null) {
return pht('Request');
} else {
@@ -157,6 +175,17 @@
return $name;
}
break;
+ case self::TYPE_UNBLOCK:
+ $action = head($new);
+
+ switch ($action) {
+ case DifferentialAction::ACTION_CLOSE:
+ return pht('Unblock');
+ case DifferentialAction::ACTION_REOPEN:
+ return pht('Block');
+ default:
+ return pht('Blocker');
+ }
}
return parent::getActionName();
@@ -195,6 +224,9 @@
case self::TYPE_INLINE:
$tags[] = self::MAILTAG_COMMENT;
break;
+ case self::TYPE_UNBLOCK:
+ $tags[] = self::MAILTAG_UNBLOCK;
+ break;
}
if (!$tags) {
@@ -287,7 +319,24 @@
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
return pht('This revision now requires review to proceed.');
}
- }
+ case self::TYPE_UNBLOCK:
+ $blocker_phid = key($new);
+ $action = head($new);
+
+ switch ($action) {
+ case DifferentialAction::ACTION_CLOSE:
+ return pht(
+ '%s closed blocking revision %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($blocker_phid));
+
+ case DifferentialAction::ACTION_REOPEN:
+ return pht(
+ '%s reopened blocking revision %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($blocker_phid));
+ }
+ }
return parent::getTitle();
}
@@ -445,7 +494,25 @@
'%s now requires review to proceed.',
$object_link);
}
- }
+ case self::TYPE_UNBLOCK:
+ $blocker_phid = key($new);
+ $action = head($new);
+
+ switch ($action) {
+ case DifferentialAction::ACTION_REOPEN:
+ return pht(
+ '%s reopened %s, a revision blocking %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($blocker_phid),
+ $this->renderHandleLink($object_phid));
+ case DifferentialAction::ACTION_CLOSE:
+ return pht(
+ '%s closed %s, a revision blocking %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($blocker_phid),
+ $this->renderHandleLink($object_phid));
+ }
+ }
return parent::getTitleForFeed();
}
@@ -488,6 +555,8 @@
case DifferentialAction::ACTION_CLAIM:
return 'fa-flag';
}
+ case self::TYPE_UNBLOCK:
+ return 'fa-shield';
case PhabricatorTransactions::TYPE_EDGE:
switch ($this->getMetadataValue('edge:type')) {
case DifferentialRevisionHasReviewerEdgeType::EDGECONST:

File Metadata

Mime Type
text/plain
Expires
Dec 11 2025, 5:14 PM (5 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
13700988
Default Alt Text
D12823.id32447.diff (8 KB)

Event Timeline