diff --git a/src/applications/differential/editor/DifferentialRevisionEditor.php b/src/applications/differential/editor/DifferentialRevisionEditor.php index ee1b23ff9c..e4dc8db969 100644 --- a/src/applications/differential/editor/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/DifferentialRevisionEditor.php @@ -162,6 +162,18 @@ final class DifferentialRevisionEditor extends PhabricatorEditor { $this->cc = $revision->getCCPHIDs(); } + if ($is_new) { + $content_blocks = array(); + foreach ($this->auxiliaryFields as $field) { + if ($field->shouldExtractMentions()) { + $content_blocks[] = $field->renderValueForCommitMessage(false); + } + } + $phids = PhabricatorMarkupEngine::extractPHIDsFromMentions( + $content_blocks); + $this->cc = array_unique(array_merge($this->cc, $phids)); + } + $diff = $this->getDiff(); if ($diff) { $revision->setLineCount($diff->getLineCount()); diff --git a/src/applications/differential/field/specification/DifferentialFieldSpecification.php b/src/applications/differential/field/specification/DifferentialFieldSpecification.php index cce1c250f9..2f78967d7d 100644 --- a/src/applications/differential/field/specification/DifferentialFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialFieldSpecification.php @@ -165,6 +165,20 @@ abstract class DifferentialFieldSpecification { return; } + /** + * Determine if user mentions should be extracted from the value and added to + * CC when creating revision. Mentions are then extracted from the string + * returned by @{method:renderValueForCommitMessage}. + * + * By default, mentions are not extracted. + * + * @return bool + * @task edit + */ + public function shouldExtractMentions() { + return false; + } + /** * Hook for applying revision changes via the editor. Normally, you should * not implement this, but a number of builtin fields use the revision object diff --git a/src/applications/differential/field/specification/DifferentialSummaryFieldSpecification.php b/src/applications/differential/field/specification/DifferentialSummaryFieldSpecification.php index 20a11bfef7..59beb0f8c9 100644 --- a/src/applications/differential/field/specification/DifferentialSummaryFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialSummaryFieldSpecification.php @@ -25,6 +25,10 @@ final class DifferentialSummaryFieldSpecification ->setValue($this->summary); } + public function shouldExtractMentions() { + return true; + } + public function willWriteRevision(DifferentialRevisionEditor $editor) { $this->getRevision()->setSummary($this->summary); } diff --git a/src/applications/differential/field/specification/DifferentialTestPlanFieldSpecification.php b/src/applications/differential/field/specification/DifferentialTestPlanFieldSpecification.php index e73a715f54..9f88204f05 100644 --- a/src/applications/differential/field/specification/DifferentialTestPlanFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialTestPlanFieldSpecification.php @@ -38,6 +38,10 @@ final class DifferentialTestPlanFieldSpecification ->setError($this->error); } + public function shouldExtractMentions() { + return true; + } + public function willWriteRevision(DifferentialRevisionEditor $editor) { $this->getRevision()->setTestPlan($this->plan); } diff --git a/src/applications/differential/field/specification/DifferentialTitleFieldSpecification.php b/src/applications/differential/field/specification/DifferentialTitleFieldSpecification.php index 9a785d07ab..6a1c6ce20c 100644 --- a/src/applications/differential/field/specification/DifferentialTitleFieldSpecification.php +++ b/src/applications/differential/field/specification/DifferentialTitleFieldSpecification.php @@ -29,6 +29,10 @@ final class DifferentialTitleFieldSpecification ->setValue($this->title); } + public function shouldExtractMentions() { + return true; + } + public function willWriteRevision(DifferentialRevisionEditor $editor) { $this->getRevision()->setTitle($this->title); }