@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revision substate CLOSED_FROM_ACCEPTED

Summary:
Ref T9838.

Add a Properties field to Revision, and update a `wasAcceptedBeforeClose` when closing a revision.

Test Plan:
A quick run through the obvious steps (Close with commit/manually, with or w/o accept) and calling `differential.query` shows the `wasAcceptedBeforeClose` property was setup correctly.

Pushing closed + accepted passes the relevant herald, which was my immediate issue; Pushing un-accepted is blocked.
Test the "commit" rule (Different from "pre-commit") by hacking the DB and running the "has accepted revision" rule in a test-console.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T9838

Differential Revision: https://secure.phabricator.com/D15085

authored by

Aviv Eyal and committed by
avivey
de6349dd e984f0eb

+63 -7
+2
resources/sql/autopatches/20160201.revision.properties.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_differential.differential_revision 2 + ADD properties LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT};
+2
resources/sql/autopatches/20160201.revision.properties.2.sql
··· 1 + UPDATE {$NAMESPACE}_differential.differential_revision 2 + SET properties = '{}' WHERE properties = '';
+1
src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php
··· 206 206 'statusName' => 207 207 ArcanistDifferentialRevisionStatus::getNameForRevisionStatus( 208 208 $revision->getStatus()), 209 + 'properties' => $revision->getProperties(), 209 210 'branch' => $diff->getBranch(), 210 211 'summary' => $revision->getSummary(), 211 212 'testPlan' => $revision->getTestPlan(),
+6
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 182 182 $status_revision = ArcanistDifferentialRevisionStatus::NEEDS_REVISION; 183 183 $status_plan = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED; 184 184 $status_abandoned = ArcanistDifferentialRevisionStatus::ABANDONED; 185 + $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; 185 186 186 187 switch ($xaction->getTransactionType()) { 187 188 case DifferentialTransaction::TYPE_INLINE: ··· 233 234 $object->setStatus($status_review); 234 235 return; 235 236 case DifferentialAction::ACTION_CLOSE: 237 + $old_status = $object->getStatus(); 236 238 $object->setStatus(ArcanistDifferentialRevisionStatus::CLOSED); 239 + $was_accepted = ($old_status == $status_accepted); 240 + $object->setProperty( 241 + DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED, 242 + $was_accepted); 237 243 return; 238 244 case DifferentialAction::ACTION_CLAIM: 239 245 $object->setAuthorPHID($this->getActingAsPHID());
+17
src/applications/differential/storage/DifferentialRevision.php
··· 35 35 protected $repositoryPHID; 36 36 protected $viewPolicy = PhabricatorPolicies::POLICY_USER; 37 37 protected $editPolicy = PhabricatorPolicies::POLICY_USER; 38 + protected $properties = array(); 38 39 39 40 private $relationships = self::ATTACHABLE; 40 41 private $commits = self::ATTACHABLE; ··· 52 53 53 54 const RELATION_REVIEWER = 'revw'; 54 55 const RELATION_SUBSCRIBED = 'subd'; 56 + 57 + const PROPERTY_CLOSED_FROM_ACCEPTED = 'wasAcceptedBeforeClose'; 55 58 56 59 public static function initializeNewRevision(PhabricatorUser $actor) { 57 60 $app = id(new PhabricatorApplicationQuery()) ··· 76 79 self::CONFIG_SERIALIZATION => array( 77 80 'attached' => self::SERIALIZATION_JSON, 78 81 'unsubscribed' => self::SERIALIZATION_JSON, 82 + 'properties' => self::SERIALIZATION_JSON, 79 83 ), 80 84 self::CONFIG_COLUMN_SCHEMA => array( 81 85 'title' => 'text255', ··· 112 116 ), 113 117 ), 114 118 ) + parent::getConfiguration(); 119 + } 120 + 121 + public function setProperty($key, $value) { 122 + $this->properties[$key] = $value; 123 + return $this; 124 + } 125 + 126 + public function getProperty($key, $default = null) { 127 + return idx($this->properties, $key, $default); 128 + } 129 + 130 + public function hasRevisionProperty($key) { 131 + return array_key_exists($key, $this->properties); 115 132 } 116 133 117 134 public function getMonogram() {
+24 -3
src/applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php
··· 19 19 return null; 20 20 } 21 21 22 + $status = $revision->getStatus(); 23 + 24 + switch ($status) { 25 + case ArcanistDifferentialRevisionStatus::ACCEPTED: 26 + return $revision->getPHID(); 27 + case ArcanistDifferentialRevisionStatus::CLOSED: 28 + if ($revision->hasRevisionProperty( 29 + DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED)) { 30 + 31 + if ($revision->getProperty( 32 + DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED)) { 33 + return $revision->getPHID(); 34 + } else { 35 + return null; 36 + } 37 + } else { 38 + // continue on to old-style precommitRevisionStatus 39 + break; 40 + } 41 + default: 42 + return null; 43 + } 44 + 22 45 $data = $object->getCommitData(); 23 - $status = $data->getCommitDetail( 24 - 'precommitRevisionStatus', 25 - $revision->getStatus()); 46 + $status = $data->getCommitDetail('precommitRevisionStatus'); 26 47 27 48 switch ($status) { 28 49 case ArcanistDifferentialRevisionStatus::ACCEPTED:
+11 -4
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionAcceptedHeraldField.php
··· 20 20 return null; 21 21 } 22 22 23 - $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; 24 - if ($revision->getStatus() != $status_accepted) { 25 - return null; 23 + switch ($revision->getStatus()) { 24 + case ArcanistDifferentialRevisionStatus::ACCEPTED: 25 + return $revision->getPHID(); 26 + case ArcanistDifferentialRevisionStatus::CLOSED: 27 + if ($revision->getProperty( 28 + DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED)) { 29 + 30 + return $revision->getPHID(); 31 + } 32 + break; 26 33 } 27 34 28 - return $revision->getPHID(); 35 + return null; 29 36 } 30 37 31 38 protected function getHeraldFieldStandardType() {