diff --git a/resources/sql/autopatches/20150707.herald.1.sql b/resources/sql/autopatches/20150707.herald.1.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20150707.herald.1.sql @@ -0,0 +1,55 @@ +UPDATE {$NAMESPACE}_herald.herald_condition c + JOIN {$NAMESPACE}_herald.herald_rule r + ON c.ruleID = r.id + SET c.fieldName = 'differential.diff.affected' + WHERE r.contentType = 'differential.diff' + AND c.fieldName = 'diff-file'; + +UPDATE {$NAMESPACE}_herald.herald_condition c + JOIN {$NAMESPACE}_herald.herald_rule r + ON c.ruleID = r.id + SET c.fieldName = 'differential.diff.author' + WHERE r.contentType = 'differential.diff' + AND c.fieldName = 'author'; + +UPDATE {$NAMESPACE}_herald.herald_condition c + JOIN {$NAMESPACE}_herald.herald_rule r + ON c.ruleID = r.id + SET c.fieldName = 'differential.diff.author.projects' + WHERE r.contentType = 'differential.diff' + AND c.fieldName = 'authorprojects'; + +UPDATE {$NAMESPACE}_herald.herald_condition c + JOIN {$NAMESPACE}_herald.herald_rule r + ON c.ruleID = r.id + SET c.fieldName = 'differential.diff.new' + WHERE r.contentType = 'differential.diff' + AND c.fieldName = 'diff-added-content'; + +UPDATE {$NAMESPACE}_herald.herald_condition c + JOIN {$NAMESPACE}_herald.herald_rule r + ON c.ruleID = r.id + SET c.fieldName = 'differential.diff.content' + WHERE r.contentType = 'differential.diff' + AND c.fieldName = 'diff-content'; + +UPDATE {$NAMESPACE}_herald.herald_condition c + JOIN {$NAMESPACE}_herald.herald_rule r + ON c.ruleID = r.id + SET c.fieldName = 'differential.diff.old' + WHERE r.contentType = 'differential.diff' + AND c.fieldName = 'diff-removed-content'; + +UPDATE {$NAMESPACE}_herald.herald_condition c + JOIN {$NAMESPACE}_herald.herald_rule r + ON c.ruleID = r.id + SET c.fieldName = 'differential.diff.repository' + WHERE r.contentType = 'differential.diff' + AND c.fieldName = 'repository'; + +UPDATE {$NAMESPACE}_herald.herald_condition c + JOIN {$NAMESPACE}_herald.herald_rule r + ON c.ruleID = r.id + SET c.fieldName = 'differential.diff.repository.projects' + WHERE r.contentType = 'differential.diff' + AND c.fieldName = 'repository-projects'; 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 @@ -350,12 +350,21 @@ 'DifferentialDependenciesField' => 'applications/differential/customfield/DifferentialDependenciesField.php', 'DifferentialDependsOnField' => 'applications/differential/customfield/DifferentialDependsOnField.php', 'DifferentialDiff' => 'applications/differential/storage/DifferentialDiff.php', + 'DifferentialDiffAffectedFilesHeraldField' => 'applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php', + 'DifferentialDiffAuthorHeraldField' => 'applications/differential/herald/DifferentialDiffAuthorHeraldField.php', + 'DifferentialDiffAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php', + 'DifferentialDiffContentAddedHeraldField' => 'applications/differential/herald/DifferentialDiffContentAddedHeraldField.php', + 'DifferentialDiffContentHeraldField' => 'applications/differential/herald/DifferentialDiffContentHeraldField.php', + 'DifferentialDiffContentRemovedHeraldField' => 'applications/differential/herald/DifferentialDiffContentRemovedHeraldField.php', 'DifferentialDiffCreateController' => 'applications/differential/controller/DifferentialDiffCreateController.php', 'DifferentialDiffEditor' => 'applications/differential/editor/DifferentialDiffEditor.php', + 'DifferentialDiffHeraldField' => 'applications/differential/herald/DifferentialDiffHeraldField.php', 'DifferentialDiffInlineCommentQuery' => 'applications/differential/query/DifferentialDiffInlineCommentQuery.php', 'DifferentialDiffPHIDType' => 'applications/differential/phid/DifferentialDiffPHIDType.php', 'DifferentialDiffProperty' => 'applications/differential/storage/DifferentialDiffProperty.php', 'DifferentialDiffQuery' => 'applications/differential/query/DifferentialDiffQuery.php', + 'DifferentialDiffRepositoryHeraldField' => 'applications/differential/herald/DifferentialDiffRepositoryHeraldField.php', + 'DifferentialDiffRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php', 'DifferentialDiffTableOfContentsView' => 'applications/differential/view/DifferentialDiffTableOfContentsView.php', 'DifferentialDiffTestCase' => 'applications/differential/storage/__tests__/DifferentialDiffTestCase.php', 'DifferentialDiffTransaction' => 'applications/differential/storage/DifferentialDiffTransaction.php', @@ -960,8 +969,8 @@ 'HeraldController' => 'applications/herald/controller/HeraldController.php', 'HeraldCustomAction' => 'applications/herald/extension/HeraldCustomAction.php', 'HeraldDAO' => 'applications/herald/storage/HeraldDAO.php', - 'HeraldDifferentialAdapter' => 'applications/herald/adapter/HeraldDifferentialAdapter.php', - 'HeraldDifferentialDiffAdapter' => 'applications/herald/adapter/HeraldDifferentialDiffAdapter.php', + 'HeraldDifferentialAdapter' => 'applications/differential/herald/HeraldDifferentialAdapter.php', + 'HeraldDifferentialDiffAdapter' => 'applications/differential/herald/HeraldDifferentialDiffAdapter.php', 'HeraldDifferentialRevisionAdapter' => 'applications/herald/adapter/HeraldDifferentialRevisionAdapter.php', 'HeraldDisableController' => 'applications/herald/controller/HeraldDisableController.php', 'HeraldEffect' => 'applications/herald/engine/HeraldEffect.php', @@ -3790,12 +3799,21 @@ 'PhabricatorApplicationTransactionInterface', 'PhabricatorDestructibleInterface', ), + 'DifferentialDiffAffectedFilesHeraldField' => 'DifferentialDiffHeraldField', + 'DifferentialDiffAuthorHeraldField' => 'DifferentialDiffHeraldField', + 'DifferentialDiffAuthorProjectsHeraldField' => 'DifferentialDiffHeraldField', + 'DifferentialDiffContentAddedHeraldField' => 'DifferentialDiffHeraldField', + 'DifferentialDiffContentHeraldField' => 'DifferentialDiffHeraldField', + 'DifferentialDiffContentRemovedHeraldField' => 'DifferentialDiffHeraldField', 'DifferentialDiffCreateController' => 'DifferentialController', 'DifferentialDiffEditor' => 'PhabricatorApplicationTransactionEditor', + 'DifferentialDiffHeraldField' => 'HeraldField', 'DifferentialDiffInlineCommentQuery' => 'PhabricatorDiffInlineCommentQuery', 'DifferentialDiffPHIDType' => 'PhabricatorPHIDType', 'DifferentialDiffProperty' => 'DifferentialDAO', 'DifferentialDiffQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', + 'DifferentialDiffRepositoryHeraldField' => 'DifferentialDiffHeraldField', + 'DifferentialDiffRepositoryProjectsHeraldField' => 'DifferentialDiffHeraldField', 'DifferentialDiffTableOfContentsView' => 'AphrontView', 'DifferentialDiffTestCase' => 'PhutilTestCase', 'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction', diff --git a/src/applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php b/src/applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php @@ -0,0 +1,30 @@ +getAdapter()->loadAffectedPaths(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_TEXT_LIST; + } + + public function getHeraldFieldValueType($condition) { + switch ($condition) { + case HeraldAdapter::CONDITION_EXISTS: + case HeraldAdapter::CONDITION_NOT_EXISTS: + return HeraldAdapter::VALUE_NONE; + default: + return HeraldAdapter::VALUE_TEXT; + } + } + +} diff --git a/src/applications/differential/herald/DifferentialDiffAuthorHeraldField.php b/src/applications/differential/herald/DifferentialDiffAuthorHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/herald/DifferentialDiffAuthorHeraldField.php @@ -0,0 +1,24 @@ +getAuthorPHID(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_PHID; + } + + public function getHeraldFieldValueType($condition) { + return HeraldAdapter::VALUE_USER; + } + +} diff --git a/src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php b/src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php @@ -0,0 +1,32 @@ +getAuthorPHID(), + PhabricatorProjectMemberOfProjectEdgeType::EDGECONST); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_LIST; + } + + public function getHeraldFieldValueType($condition) { + switch ($condition) { + case HeraldAdapter::CONDITION_EXISTS: + case HeraldAdapter::CONDITION_NOT_EXISTS: + return HeraldAdapter::VALUE_NONE; + default: + return HeraldAdapter::VALUE_PROJECT; + } + } + +} diff --git a/src/applications/differential/herald/DifferentialDiffContentAddedHeraldField.php b/src/applications/differential/herald/DifferentialDiffContentAddedHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/herald/DifferentialDiffContentAddedHeraldField.php @@ -0,0 +1,24 @@ +getAdapter()->loadAddedContentDictionary(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_TEXT_MAP; + } + + public function getHeraldFieldValueType($condition) { + return HeraldAdapter::VALUE_TEXT; + } + +} diff --git a/src/applications/differential/herald/DifferentialDiffContentHeraldField.php b/src/applications/differential/herald/DifferentialDiffContentHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/herald/DifferentialDiffContentHeraldField.php @@ -0,0 +1,24 @@ +getAdapter()->loadContentDictionary(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_TEXT_MAP; + } + + public function getHeraldFieldValueType($condition) { + return HeraldAdapter::VALUE_TEXT; + } + +} diff --git a/src/applications/differential/herald/DifferentialDiffContentRemovedHeraldField.php b/src/applications/differential/herald/DifferentialDiffContentRemovedHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/herald/DifferentialDiffContentRemovedHeraldField.php @@ -0,0 +1,24 @@ +getAdapter()->loadRemovedContentDictionary(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_TEXT_MAP; + } + + public function getHeraldFieldValueType($condition) { + return HeraldAdapter::VALUE_TEXT; + } + +} diff --git a/src/applications/differential/herald/DifferentialDiffHeraldField.php b/src/applications/differential/herald/DifferentialDiffHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/herald/DifferentialDiffHeraldField.php @@ -0,0 +1,9 @@ +getAdapter()->loadRepository(); + + if (!$repository) { + return null; + } + + return $repository->getPHID(); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_PHID_NULLABLE; + } + + public function getHeraldFieldValueType($condition) { + switch ($condition) { + case HeraldAdapter::CONDITION_EXISTS: + case HeraldAdapter::CONDITION_NOT_EXISTS: + return HeraldAdapter::VALUE_NONE; + default: + return HeraldAdapter::VALUE_REPOSITORY; + } + } + +} diff --git a/src/applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php b/src/applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php @@ -0,0 +1,37 @@ +getAdapter()->loadRepository(); + if (!$repository) { + return array(); + } + + return PhabricatorEdgeQuery::loadDestinationPHIDs( + $repository->getPHID(), + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); + } + + protected function getHeraldFieldStandardConditions() { + return self::STANDARD_LIST; + } + + public function getHeraldFieldValueType($condition) { + switch ($condition) { + case HeraldAdapter::CONDITION_EXISTS: + case HeraldAdapter::CONDITION_NOT_EXISTS: + return HeraldAdapter::VALUE_NONE; + default: + return HeraldAdapter::VALUE_PROJECT; + } + } + +} diff --git a/src/applications/herald/adapter/HeraldDifferentialAdapter.php b/src/applications/differential/herald/HeraldDifferentialAdapter.php rename from src/applications/herald/adapter/HeraldDifferentialAdapter.php rename to src/applications/differential/herald/HeraldDifferentialAdapter.php --- a/src/applications/herald/adapter/HeraldDifferentialAdapter.php +++ b/src/applications/differential/herald/HeraldDifferentialAdapter.php @@ -25,7 +25,6 @@ $repository = id(new PhabricatorRepositoryQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withPHIDs(array($repository_phid)) - ->needProjectPHIDs(true) ->executeOne(); } else { $repository = null; @@ -38,7 +37,7 @@ } - protected function loadAffectedPaths() { + public function loadAffectedPaths() { $changesets = $this->loadChangesets(); $paths = array(); @@ -62,18 +61,18 @@ return $changeset->getAbsoluteRepositoryPath($repository, $diff); } - protected function loadContentDictionary() { + public function loadContentDictionary() { $add_lines = DifferentialHunk::FLAG_LINES_ADDED; $rem_lines = DifferentialHunk::FLAG_LINES_REMOVED; $mask = ($add_lines | $rem_lines); return $this->loadContentWithMask($mask); } - protected function loadAddedContentDictionary() { + public function loadAddedContentDictionary() { return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_ADDED); } - protected function loadRemovedContentDictionary() { + public function loadRemovedContentDictionary() { return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_REMOVED); } diff --git a/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php b/src/applications/differential/herald/HeraldDifferentialDiffAdapter.php rename from src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php rename to src/applications/differential/herald/HeraldDifferentialDiffAdapter.php --- a/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php +++ b/src/applications/differential/herald/HeraldDifferentialDiffAdapter.php @@ -53,31 +53,12 @@ } } - public function getFields() { - return array_merge( - array( - self::FIELD_AUTHOR, - self::FIELD_AUTHOR_PROJECTS, - self::FIELD_REPOSITORY, - self::FIELD_REPOSITORY_PROJECTS, - self::FIELD_DIFF_FILE, - self::FIELD_DIFF_CONTENT, - self::FIELD_DIFF_ADDED_CONTENT, - self::FIELD_DIFF_REMOVED_CONTENT, - ), - parent::getFields()); - } - public function getRepetitionOptions() { return array( HeraldRepetitionPolicyConfig::FIRST, ); } - public function getPHID() { - return $this->getObject()->getPHID(); - } - public function getHeraldName() { return pht('New Diff'); } @@ -88,48 +69,6 @@ ) + parent::getActionNameMap($rule_type); } - public function getHeraldField($field) { - switch ($field) { - case self::FIELD_AUTHOR: - return $this->getObject()->getAuthorPHID(); - break; - case self::FIELD_AUTHOR_PROJECTS: - $author_phid = $this->getHeraldField(self::FIELD_AUTHOR); - if (!$author_phid) { - return array(); - } - - $projects = id(new PhabricatorProjectQuery()) - ->setViewer(PhabricatorUser::getOmnipotentUser()) - ->withMemberPHIDs(array($author_phid)) - ->execute(); - - return mpull($projects, 'getPHID'); - case self::FIELD_DIFF_FILE: - return $this->loadAffectedPaths(); - case self::FIELD_REPOSITORY: - $repository = $this->loadRepository(); - if (!$repository) { - return null; - } - return $repository->getPHID(); - case self::FIELD_REPOSITORY_PROJECTS: - $repository = $this->loadRepository(); - if (!$repository) { - return array(); - } - return $repository->getProjectPHIDs(); - case self::FIELD_DIFF_CONTENT: - return $this->loadContentDictionary(); - case self::FIELD_DIFF_ADDED_CONTENT: - return $this->loadAddedContentDictionary(); - case self::FIELD_DIFF_REMOVED_CONTENT: - return $this->loadRemovedContentDictionary(); - } - - return parent::getHeraldField($field); - } - public function getActions($rule_type) { switch ($rule_type) { case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: