@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.

Modularize all DifferentialRevision fields

Summary: Ref T8726. Make all the DifferentialRevision stuff modular.

Test Plan:
- Created a rule with all fields.
- Ran upgrade.
- Saw all fields preserved with new modular versions.
- Used test console to run rule with all fields, verified field values as broadly sensible.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8726

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

+518 -97
+90
resources/sql/autopatches/20150708.herald.1.sql
··· 1 + UPDATE {$NAMESPACE}_herald.herald_condition c 2 + JOIN {$NAMESPACE}_herald.herald_rule r 3 + ON c.ruleID = r.id 4 + SET c.fieldName = 'differential.revision.diff.affected' 5 + WHERE r.contentType = 'differential' 6 + AND c.fieldName = 'diff-file'; 7 + 8 + UPDATE {$NAMESPACE}_herald.herald_condition c 9 + JOIN {$NAMESPACE}_herald.herald_rule r 10 + ON c.ruleID = r.id 11 + SET c.fieldName = 'differential.revision.author' 12 + WHERE r.contentType = 'differential' 13 + AND c.fieldName = 'author'; 14 + 15 + UPDATE {$NAMESPACE}_herald.herald_condition c 16 + JOIN {$NAMESPACE}_herald.herald_rule r 17 + ON c.ruleID = r.id 18 + SET c.fieldName = 'differential.revision.author.projects' 19 + WHERE r.contentType = 'differential' 20 + AND c.fieldName = 'authorprojects'; 21 + 22 + UPDATE {$NAMESPACE}_herald.herald_condition c 23 + JOIN {$NAMESPACE}_herald.herald_rule r 24 + ON c.ruleID = r.id 25 + SET c.fieldName = 'differential.revision.diff.new' 26 + WHERE r.contentType = 'differential' 27 + AND c.fieldName = 'diff-added-content'; 28 + 29 + UPDATE {$NAMESPACE}_herald.herald_condition c 30 + JOIN {$NAMESPACE}_herald.herald_rule r 31 + ON c.ruleID = r.id 32 + SET c.fieldName = 'differential.revision.diff.content' 33 + WHERE r.contentType = 'differential' 34 + AND c.fieldName = 'diff-content'; 35 + 36 + UPDATE {$NAMESPACE}_herald.herald_condition c 37 + JOIN {$NAMESPACE}_herald.herald_rule r 38 + ON c.ruleID = r.id 39 + SET c.fieldName = 'differential.revision.diff.old' 40 + WHERE r.contentType = 'differential' 41 + AND c.fieldName = 'diff-removed-content'; 42 + 43 + UPDATE {$NAMESPACE}_herald.herald_condition c 44 + JOIN {$NAMESPACE}_herald.herald_rule r 45 + ON c.ruleID = r.id 46 + SET c.fieldName = 'differential.revision.package' 47 + WHERE r.contentType = 'differential' 48 + AND c.fieldName = 'affected-package'; 49 + 50 + UPDATE {$NAMESPACE}_herald.herald_condition c 51 + JOIN {$NAMESPACE}_herald.herald_rule r 52 + ON c.ruleID = r.id 53 + SET c.fieldName = 'differential.revision.repository' 54 + WHERE r.contentType = 'differential' 55 + AND c.fieldName = 'repository'; 56 + 57 + UPDATE {$NAMESPACE}_herald.herald_condition c 58 + JOIN {$NAMESPACE}_herald.herald_rule r 59 + ON c.ruleID = r.id 60 + SET c.fieldName = 'differential.revision.repository.projects' 61 + WHERE r.contentType = 'differential' 62 + AND c.fieldName = 'repository-projects'; 63 + 64 + UPDATE {$NAMESPACE}_herald.herald_condition c 65 + JOIN {$NAMESPACE}_herald.herald_rule r 66 + ON c.ruleID = r.id 67 + SET c.fieldName = 'differential.revision.reviewers' 68 + WHERE r.contentType = 'differential' 69 + AND c.fieldName = 'reviewers'; 70 + 71 + UPDATE {$NAMESPACE}_herald.herald_condition c 72 + JOIN {$NAMESPACE}_herald.herald_rule r 73 + ON c.ruleID = r.id 74 + SET c.fieldName = 'differential.revision.summary' 75 + WHERE r.contentType = 'differential' 76 + AND c.fieldName = 'body'; 77 + 78 + UPDATE {$NAMESPACE}_herald.herald_condition c 79 + JOIN {$NAMESPACE}_herald.herald_rule r 80 + ON c.ruleID = r.id 81 + SET c.fieldName = 'differential.revision.title' 82 + WHERE r.contentType = 'differential' 83 + AND c.fieldName = 'title'; 84 + 85 + UPDATE {$NAMESPACE}_herald.herald_condition c 86 + JOIN {$NAMESPACE}_herald.herald_rule r 87 + ON c.ruleID = r.id 88 + SET c.fieldName = 'differential.revision.package.owners' 89 + WHERE r.contentType = 'differential' 90 + AND c.fieldName = 'affected-package-owner';
+29 -1
src/__phutil_library_map__.php
··· 436 436 'DifferentialReviewersField' => 'applications/differential/customfield/DifferentialReviewersField.php', 437 437 'DifferentialReviewersView' => 'applications/differential/view/DifferentialReviewersView.php', 438 438 'DifferentialRevision' => 'applications/differential/storage/DifferentialRevision.php', 439 + 'DifferentialRevisionAffectedFilesHeraldField' => 'applications/differential/herald/DifferentialRevisionAffectedFilesHeraldField.php', 440 + 'DifferentialRevisionAuthorHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorHeraldField.php', 441 + 'DifferentialRevisionAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php', 439 442 'DifferentialRevisionCloseDetailsController' => 'applications/differential/controller/DifferentialRevisionCloseDetailsController.php', 443 + 'DifferentialRevisionContentAddedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php', 444 + 'DifferentialRevisionContentHeraldField' => 'applications/differential/herald/DifferentialRevisionContentHeraldField.php', 445 + 'DifferentialRevisionContentRemovedHeraldField' => 'applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php', 440 446 'DifferentialRevisionControlSystem' => 'applications/differential/constants/DifferentialRevisionControlSystem.php', 441 447 'DifferentialRevisionDependedOnByRevisionEdgeType' => 'applications/differential/edge/DifferentialRevisionDependedOnByRevisionEdgeType.php', 442 448 'DifferentialRevisionDependsOnRevisionEdgeType' => 'applications/differential/edge/DifferentialRevisionDependsOnRevisionEdgeType.php', ··· 445 451 'DifferentialRevisionHasCommitEdgeType' => 'applications/differential/edge/DifferentialRevisionHasCommitEdgeType.php', 446 452 'DifferentialRevisionHasReviewerEdgeType' => 'applications/differential/edge/DifferentialRevisionHasReviewerEdgeType.php', 447 453 'DifferentialRevisionHasTaskEdgeType' => 'applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php', 454 + 'DifferentialRevisionHeraldField' => 'applications/differential/herald/DifferentialRevisionHeraldField.php', 448 455 'DifferentialRevisionIDField' => 'applications/differential/customfield/DifferentialRevisionIDField.php', 449 456 'DifferentialRevisionLandController' => 'applications/differential/controller/DifferentialRevisionLandController.php', 450 457 'DifferentialRevisionListController' => 'applications/differential/controller/DifferentialRevisionListController.php', 451 458 'DifferentialRevisionListView' => 'applications/differential/view/DifferentialRevisionListView.php', 452 459 'DifferentialRevisionMailReceiver' => 'applications/differential/mail/DifferentialRevisionMailReceiver.php', 453 460 'DifferentialRevisionPHIDType' => 'applications/differential/phid/DifferentialRevisionPHIDType.php', 461 + 'DifferentialRevisionPackageHeraldField' => 'applications/differential/herald/DifferentialRevisionPackageHeraldField.php', 462 + 'DifferentialRevisionPackageOwnerHeraldField' => 'applications/differential/herald/DifferentialRevisionPackageOwnerHeraldField.php', 454 463 'DifferentialRevisionQuery' => 'applications/differential/query/DifferentialRevisionQuery.php', 464 + 'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php', 465 + 'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php', 466 + 'DifferentialRevisionReviewersHeraldField' => 'applications/differential/herald/DifferentialRevisionReviewersHeraldField.php', 455 467 'DifferentialRevisionSearchEngine' => 'applications/differential/query/DifferentialRevisionSearchEngine.php', 456 468 'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php', 469 + 'DifferentialRevisionSummaryHeraldField' => 'applications/differential/herald/DifferentialRevisionSummaryHeraldField.php', 470 + 'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php', 457 471 'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/DifferentialRevisionUpdateHistoryView.php', 458 472 'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php', 459 473 'DifferentialSchemaSpec' => 'applications/differential/storage/DifferentialSchemaSpec.php', ··· 971 985 'HeraldDAO' => 'applications/herald/storage/HeraldDAO.php', 972 986 'HeraldDifferentialAdapter' => 'applications/differential/herald/HeraldDifferentialAdapter.php', 973 987 'HeraldDifferentialDiffAdapter' => 'applications/differential/herald/HeraldDifferentialDiffAdapter.php', 974 - 'HeraldDifferentialRevisionAdapter' => 'applications/herald/adapter/HeraldDifferentialRevisionAdapter.php', 988 + 'HeraldDifferentialRevisionAdapter' => 'applications/differential/herald/HeraldDifferentialRevisionAdapter.php', 975 989 'HeraldDisableController' => 'applications/herald/controller/HeraldDisableController.php', 976 990 'HeraldEffect' => 'applications/herald/engine/HeraldEffect.php', 977 991 'HeraldEngine' => 'applications/herald/engine/HeraldEngine.php', ··· 3905 3919 'PhabricatorDestructibleInterface', 3906 3920 'PhabricatorProjectInterface', 3907 3921 ), 3922 + 'DifferentialRevisionAffectedFilesHeraldField' => 'DifferentialRevisionHeraldField', 3923 + 'DifferentialRevisionAuthorHeraldField' => 'DifferentialRevisionHeraldField', 3924 + 'DifferentialRevisionAuthorProjectsHeraldField' => 'DifferentialRevisionHeraldField', 3908 3925 'DifferentialRevisionCloseDetailsController' => 'DifferentialController', 3926 + 'DifferentialRevisionContentAddedHeraldField' => 'DifferentialRevisionHeraldField', 3927 + 'DifferentialRevisionContentHeraldField' => 'DifferentialRevisionHeraldField', 3928 + 'DifferentialRevisionContentRemovedHeraldField' => 'DifferentialRevisionHeraldField', 3909 3929 'DifferentialRevisionControlSystem' => 'Phobject', 3910 3930 'DifferentialRevisionDependedOnByRevisionEdgeType' => 'PhabricatorEdgeType', 3911 3931 'DifferentialRevisionDependsOnRevisionEdgeType' => 'PhabricatorEdgeType', ··· 3914 3934 'DifferentialRevisionHasCommitEdgeType' => 'PhabricatorEdgeType', 3915 3935 'DifferentialRevisionHasReviewerEdgeType' => 'PhabricatorEdgeType', 3916 3936 'DifferentialRevisionHasTaskEdgeType' => 'PhabricatorEdgeType', 3937 + 'DifferentialRevisionHeraldField' => 'HeraldField', 3917 3938 'DifferentialRevisionIDField' => 'DifferentialCustomField', 3918 3939 'DifferentialRevisionLandController' => 'DifferentialController', 3919 3940 'DifferentialRevisionListController' => 'DifferentialController', 3920 3941 'DifferentialRevisionListView' => 'AphrontView', 3921 3942 'DifferentialRevisionMailReceiver' => 'PhabricatorObjectMailReceiver', 3922 3943 'DifferentialRevisionPHIDType' => 'PhabricatorPHIDType', 3944 + 'DifferentialRevisionPackageHeraldField' => 'DifferentialRevisionHeraldField', 3945 + 'DifferentialRevisionPackageOwnerHeraldField' => 'DifferentialRevisionHeraldField', 3923 3946 'DifferentialRevisionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3947 + 'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField', 3948 + 'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField', 3949 + 'DifferentialRevisionReviewersHeraldField' => 'DifferentialRevisionHeraldField', 3924 3950 'DifferentialRevisionSearchEngine' => 'PhabricatorApplicationSearchEngine', 3925 3951 'DifferentialRevisionStatus' => 'Phobject', 3952 + 'DifferentialRevisionSummaryHeraldField' => 'DifferentialRevisionHeraldField', 3953 + 'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField', 3926 3954 'DifferentialRevisionUpdateHistoryView' => 'AphrontView', 3927 3955 'DifferentialRevisionViewController' => 'DifferentialController', 3928 3956 'DifferentialSchemaSpec' => 'PhabricatorConfigSchemaSpec',
+30
src/applications/differential/herald/DifferentialRevisionAffectedFilesHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionAffectedFilesHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.diff.affected'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Affected files'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->loadAffectedPaths(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_LIST; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + switch ($condition) { 22 + case HeraldAdapter::CONDITION_EXISTS: 23 + case HeraldAdapter::CONDITION_NOT_EXISTS: 24 + return HeraldAdapter::VALUE_NONE; 25 + default: 26 + return HeraldAdapter::VALUE_TEXT; 27 + } 28 + } 29 + 30 + }
+24
src/applications/differential/herald/DifferentialRevisionAuthorHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionAuthorHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.author'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Author'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $object->getAuthorPHID(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_PHID; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_USER; 22 + } 23 + 24 + }
+32
src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionAuthorProjectsHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.author.projects'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht("Author's projects"); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return PhabricatorEdgeQuery::loadDestinationPHIDs( 14 + $object->getAuthorPHID(), 15 + PhabricatorProjectMemberOfProjectEdgeType::EDGECONST); 16 + } 17 + 18 + protected function getHeraldFieldStandardConditions() { 19 + return self::STANDARD_LIST; 20 + } 21 + 22 + public function getHeraldFieldValueType($condition) { 23 + switch ($condition) { 24 + case HeraldAdapter::CONDITION_EXISTS: 25 + case HeraldAdapter::CONDITION_NOT_EXISTS: 26 + return HeraldAdapter::VALUE_NONE; 27 + default: 28 + return HeraldAdapter::VALUE_PROJECT; 29 + } 30 + } 31 + 32 + }
+24
src/applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionContentAddedHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.diff.new'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Added file content'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->loadAddedContentDictionary(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_MAP; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+24
src/applications/differential/herald/DifferentialRevisionContentHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionContentHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.diff.content'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Changed file content'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->loadContentDictionary(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_MAP; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+24
src/applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionContentRemovedHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.diff.old'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Removed file content'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->loadRemovedContentDictionary(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_MAP; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+9
src/applications/differential/herald/DifferentialRevisionHeraldField.php
··· 1 + <?php 2 + 3 + abstract class DifferentialRevisionHeraldField extends HeraldField { 4 + 5 + public function supportsObject($object) { 6 + return ($object instanceof DifferentialRevision); 7 + } 8 + 9 + }
+31
src/applications/differential/herald/DifferentialRevisionPackageHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionPackageHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.package'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Affected packages'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $packages = $this->getAdapter()->loadAffectedPackages(); 14 + return mpull($packages, 'getPHID'); 15 + } 16 + 17 + protected function getHeraldFieldStandardConditions() { 18 + return self::STANDARD_LIST; 19 + } 20 + 21 + public function getHeraldFieldValueType($condition) { 22 + switch ($condition) { 23 + case HeraldAdapter::CONDITION_EXISTS: 24 + case HeraldAdapter::CONDITION_NOT_EXISTS: 25 + return HeraldAdapter::VALUE_NONE; 26 + default: 27 + return HeraldAdapter::VALUE_OWNERS_PACKAGE; 28 + } 29 + } 30 + 31 + }
+36
src/applications/differential/herald/DifferentialRevisionPackageOwnerHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionPackageOwnerHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.package.owners'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Affected package owners'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $packages = $this->getAdapter()->loadAffectedPackages(); 14 + if (!$packages) { 15 + return array(); 16 + } 17 + 18 + $owners = PhabricatorOwnersOwner::loadAllForPackages($packages); 19 + return mpull($owners, 'getUserPHID'); 20 + } 21 + 22 + protected function getHeraldFieldStandardConditions() { 23 + return self::STANDARD_LIST; 24 + } 25 + 26 + public function getHeraldFieldValueType($condition) { 27 + switch ($condition) { 28 + case HeraldAdapter::CONDITION_EXISTS: 29 + case HeraldAdapter::CONDITION_NOT_EXISTS: 30 + return HeraldAdapter::VALUE_NONE; 31 + default: 32 + return HeraldAdapter::VALUE_USER_OR_PROJECT; 33 + } 34 + } 35 + 36 + }
+36
src/applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionRepositoryHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.repository'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Repository'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $repository = $this->getAdapter()->loadRepository(); 14 + 15 + if (!$repository) { 16 + return null; 17 + } 18 + 19 + return $repository->getPHID(); 20 + } 21 + 22 + protected function getHeraldFieldStandardConditions() { 23 + return self::STANDARD_PHID_NULLABLE; 24 + } 25 + 26 + public function getHeraldFieldValueType($condition) { 27 + switch ($condition) { 28 + case HeraldAdapter::CONDITION_EXISTS: 29 + case HeraldAdapter::CONDITION_NOT_EXISTS: 30 + return HeraldAdapter::VALUE_NONE; 31 + default: 32 + return HeraldAdapter::VALUE_REPOSITORY; 33 + } 34 + } 35 + 36 + }
+37
src/applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionRepositoryProjectsHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.repository.projects'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Repository projects'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $repository = $this->getAdapter()->loadRepository(); 14 + if (!$repository) { 15 + return array(); 16 + } 17 + 18 + return PhabricatorEdgeQuery::loadDestinationPHIDs( 19 + $repository->getPHID(), 20 + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 21 + } 22 + 23 + protected function getHeraldFieldStandardConditions() { 24 + return self::STANDARD_LIST; 25 + } 26 + 27 + public function getHeraldFieldValueType($condition) { 28 + switch ($condition) { 29 + case HeraldAdapter::CONDITION_EXISTS: 30 + case HeraldAdapter::CONDITION_NOT_EXISTS: 31 + return HeraldAdapter::VALUE_NONE; 32 + default: 33 + return HeraldAdapter::VALUE_PROJECT; 34 + } 35 + } 36 + 37 + }
+30
src/applications/differential/herald/DifferentialRevisionReviewersHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionReviewersHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.reviewers'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Reviewers'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->loadReviewers(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_LIST; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + switch ($condition) { 22 + case HeraldAdapter::CONDITION_EXISTS: 23 + case HeraldAdapter::CONDITION_NOT_EXISTS: 24 + return HeraldAdapter::VALUE_NONE; 25 + default: 26 + return HeraldAdapter::VALUE_USER_OR_PROJECT; 27 + } 28 + } 29 + 30 + }
+27
src/applications/differential/herald/DifferentialRevisionSummaryHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionSummaryHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.summary'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Revision summary'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + // NOTE: For historical reasons, this field includes the test plan. We 14 + // could maybe try to fix this some day, but it probably aligns reasonably 15 + // well with user expectation without harming anything. 16 + return $object->getSummary()."\n\n".$object->getTestPlan(); 17 + } 18 + 19 + protected function getHeraldFieldStandardConditions() { 20 + return self::STANDARD_TEXT; 21 + } 22 + 23 + public function getHeraldFieldValueType($condition) { 24 + return HeraldAdapter::VALUE_TEXT; 25 + } 26 + 27 + }
+24
src/applications/differential/herald/DifferentialRevisionTitleHeraldField.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionTitleHeraldField 4 + extends DifferentialRevisionHeraldField { 5 + 6 + const FIELDCONST = 'differential.revision.title'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Revision title'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $object->getTitle(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+1 -1
src/applications/diffusion/herald/DiffusionCommitPackageOwnerHeraldField.php
··· 30 30 case HeraldAdapter::CONDITION_NOT_EXISTS: 31 31 return HeraldAdapter::VALUE_NONE; 32 32 default: 33 - return HeraldAdapter::VALUE_USER; 33 + return HeraldAdapter::VALUE_USER_OR_PROJECT; 34 34 } 35 35 } 36 36
-5
src/applications/herald/adapter/HeraldAdapter.php
··· 6 6 const FIELD_BODY = 'body'; 7 7 const FIELD_AUTHOR = 'author'; 8 8 const FIELD_REVIEWER = 'reviewer'; 9 - const FIELD_REVIEWERS = 'reviewers'; 10 9 const FIELD_COMMITTER = 'committer'; 11 10 const FIELD_DIFF_FILE = 'diff-file'; 12 11 const FIELD_DIFF_CONTENT = 'diff-content'; ··· 367 366 self::FIELD_AUTHOR => pht('Author'), 368 367 self::FIELD_COMMITTER => pht('Committer'), 369 368 self::FIELD_REVIEWER => pht('Reviewer'), 370 - self::FIELD_REVIEWERS => pht('Reviewers'), 371 369 self::FIELD_DIFF_FILE => pht('Any changed filename'), 372 370 self::FIELD_DIFF_CONTENT => pht('Any changed file content'), 373 371 self::FIELD_DIFF_ADDED_CONTENT => pht('Any added file content'), ··· 459 457 self::CONDITION_EXISTS, 460 458 self::CONDITION_NOT_EXISTS, 461 459 ); 462 - case self::FIELD_REVIEWERS: 463 460 case self::FIELD_AUTHOR_PROJECTS: 464 461 case self::FIELD_AFFECTED_PACKAGE: 465 462 case self::FIELD_AFFECTED_PACKAGE_OWNER: ··· 922 919 case self::FIELD_PUSHER_PROJECTS: 923 920 case self::FIELD_REPOSITORY_PROJECTS: 924 921 return self::VALUE_PROJECT; 925 - case self::FIELD_REVIEWERS: 926 - return self::VALUE_USER_OR_PROJECT; 927 922 default: 928 923 return self::VALUE_USER; 929 924 }
+10 -90
src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php
··· 3 3 final class HeraldDifferentialRevisionAdapter 4 4 extends HeraldDifferentialAdapter { 5 5 6 - protected $diff; 7 6 protected $revision; 8 7 9 8 protected $explicitReviewers; ··· 32 31 return $this->revision; 33 32 } 34 33 35 - public function getDiff() { 36 - return $this->diff; 37 - } 38 - 39 34 public function getAdapterContentType() { 40 35 return 'differential'; 41 36 } ··· 60 55 default: 61 56 return false; 62 57 } 63 - } 64 - 65 - public function getFields() { 66 - return array_merge( 67 - array( 68 - self::FIELD_TITLE, 69 - self::FIELD_BODY, 70 - self::FIELD_AUTHOR, 71 - self::FIELD_AUTHOR_PROJECTS, 72 - self::FIELD_REVIEWERS, 73 - self::FIELD_REPOSITORY, 74 - self::FIELD_REPOSITORY_PROJECTS, 75 - self::FIELD_DIFF_FILE, 76 - self::FIELD_DIFF_CONTENT, 77 - self::FIELD_DIFF_ADDED_CONTENT, 78 - self::FIELD_DIFF_REMOVED_CONTENT, 79 - self::FIELD_AFFECTED_PACKAGE, 80 - self::FIELD_AFFECTED_PACKAGE_OWNER, 81 - ), 82 - parent::getFields()); 83 58 } 84 59 85 60 public function getRepetitionOptions() { ··· 103 78 ->executeOne(); 104 79 105 80 $object->revision = $revision; 106 - $object->diff = $diff; 81 + $object->setDiff($diff); 107 82 108 83 return $object; 109 84 } ··· 129 104 return $this->buildPlans; 130 105 } 131 106 132 - public function getPHID() { 133 - return $this->revision->getPHID(); 134 - } 135 - 136 107 public function getHeraldName() { 137 108 return $this->revision->getTitle(); 138 109 } 139 110 140 111 protected function loadChangesets() { 141 112 if ($this->changesets === null) { 142 - $this->changesets = $this->diff->loadChangesets(); 113 + $this->changesets = $this->getDiff()->loadChangesets(); 143 114 } 144 115 return $this->changesets; 145 116 } ··· 175 146 return $this->affectedPackages; 176 147 } 177 148 178 - public function getHeraldField($field) { 179 - switch ($field) { 180 - case self::FIELD_TITLE: 181 - return $this->revision->getTitle(); 182 - break; 183 - case self::FIELD_BODY: 184 - return $this->revision->getSummary()."\n". 185 - $this->revision->getTestPlan(); 186 - break; 187 - case self::FIELD_AUTHOR: 188 - return $this->revision->getAuthorPHID(); 189 - break; 190 - case self::FIELD_AUTHOR_PROJECTS: 191 - $author_phid = $this->revision->getAuthorPHID(); 192 - if (!$author_phid) { 193 - return array(); 194 - } 195 - 196 - $projects = id(new PhabricatorProjectQuery()) 197 - ->setViewer(PhabricatorUser::getOmnipotentUser()) 198 - ->withMemberPHIDs(array($author_phid)) 199 - ->execute(); 200 - 201 - return mpull($projects, 'getPHID'); 202 - case self::FIELD_DIFF_FILE: 203 - return $this->loadAffectedPaths(); 204 - case self::FIELD_REVIEWERS: 205 - if (isset($this->explicitReviewers)) { 206 - return array_keys($this->explicitReviewers); 207 - } else { 208 - return $this->revision->getReviewers(); 209 - } 210 - case self::FIELD_REPOSITORY: 211 - $repository = $this->loadRepository(); 212 - if (!$repository) { 213 - return null; 214 - } 215 - return $repository->getPHID(); 216 - case self::FIELD_REPOSITORY_PROJECTS: 217 - $repository = $this->loadRepository(); 218 - if (!$repository) { 219 - return array(); 220 - } 221 - return $repository->getProjectPHIDs(); 222 - case self::FIELD_DIFF_CONTENT: 223 - return $this->loadContentDictionary(); 224 - case self::FIELD_DIFF_ADDED_CONTENT: 225 - return $this->loadAddedContentDictionary(); 226 - case self::FIELD_DIFF_REMOVED_CONTENT: 227 - return $this->loadRemovedContentDictionary(); 228 - case self::FIELD_AFFECTED_PACKAGE: 229 - $packages = $this->loadAffectedPackages(); 230 - return mpull($packages, 'getPHID'); 231 - case self::FIELD_AFFECTED_PACKAGE_OWNER: 232 - $packages = $this->loadAffectedPackages(); 233 - return PhabricatorOwnersOwner::loadAffiliatedUserPHIDs( 234 - mpull($packages, 'getID')); 149 + public function loadReviewers() { 150 + // TODO: This can probably go away as I believe it's just a performance 151 + // optimization, just retaining it while modularizing fields to limit the 152 + // scope of that change. 153 + if (isset($this->explicitReviewers)) { 154 + return array_keys($this->explicitReviewers); 155 + } else { 156 + return $this->revision->getReviewers(); 235 157 } 236 - 237 - return parent::getHeraldField($field); 238 158 } 239 159 240 160 public function getActions($rule_type) {