Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15337078
D13590.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
19 KB
Referenced Files
None
Subscribers
None
D13590.diff
View Options
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 @@
+<?php
+
+final class DifferentialDiffAffectedFilesHeraldField
+ extends DifferentialDiffHeraldField {
+
+ const FIELDCONST = 'differential.diff.affected';
+
+ public function getHeraldFieldName() {
+ return pht('Affected files');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $this->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 @@
+<?php
+
+final class DifferentialDiffAuthorHeraldField
+ extends DifferentialDiffHeraldField {
+
+ const FIELDCONST = 'differential.diff.author';
+
+ public function getHeraldFieldName() {
+ return pht('Author');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $object->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 @@
+<?php
+
+final class DifferentialDiffAuthorProjectsHeraldField
+ extends DifferentialDiffHeraldField {
+
+ const FIELDCONST = 'differential.diff.author.projects';
+
+ public function getHeraldFieldName() {
+ return pht("Author's projects");
+ }
+
+ public function getHeraldFieldValue($object) {
+ return PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $object->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 @@
+<?php
+
+final class DifferentialDiffContentAddedHeraldField
+ extends DifferentialDiffHeraldField {
+
+ const FIELDCONST = 'differential.diff.new';
+
+ public function getHeraldFieldName() {
+ return pht('Added file content');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $this->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 @@
+<?php
+
+final class DifferentialDiffContentHeraldField
+ extends DifferentialDiffHeraldField {
+
+ const FIELDCONST = 'differential.diff.content';
+
+ public function getHeraldFieldName() {
+ return pht('Changed file content');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $this->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 @@
+<?php
+
+final class DifferentialDiffContentRemovedHeraldField
+ extends DifferentialDiffHeraldField {
+
+ const FIELDCONST = 'differential.diff.old';
+
+ public function getHeraldFieldName() {
+ return pht('Removed file content');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $this->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 @@
+<?php
+
+abstract class DifferentialDiffHeraldField extends HeraldField {
+
+ public function supportsObject($object) {
+ return ($object instanceof DifferentialDiff);
+ }
+
+}
diff --git a/src/applications/differential/herald/DifferentialDiffRepositoryHeraldField.php b/src/applications/differential/herald/DifferentialDiffRepositoryHeraldField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/herald/DifferentialDiffRepositoryHeraldField.php
@@ -0,0 +1,36 @@
+<?php
+
+final class DifferentialDiffRepositoryHeraldField
+ extends DifferentialDiffHeraldField {
+
+ const FIELDCONST = 'differential.diff.repository';
+
+ public function getHeraldFieldName() {
+ return pht('Repository');
+ }
+
+ public function getHeraldFieldValue($object) {
+ $repository = $this->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 @@
+<?php
+
+final class DifferentialDiffRepositoryProjectsHeraldField
+ extends DifferentialDiffHeraldField {
+
+ const FIELDCONST = 'differential.diff.repository.projects';
+
+ public function getHeraldFieldName() {
+ return pht('Repository projects');
+ }
+
+ public function getHeraldFieldValue($object) {
+ $repository = $this->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:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 10, 3:57 AM (3 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7395820
Default Alt Text
D13590.diff (19 KB)
Attached To
Mode
D13590: Modernize all Herald DifferentialDiff fields
Attached
Detach File
Event Timeline
Log In to Comment