Page MenuHomePhabricator

D7375.id16595.diff

D7375.id16595.diff

diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php
--- a/src/applications/differential/controller/DifferentialRevisionViewController.php
+++ b/src/applications/differential/controller/DifferentialRevisionViewController.php
@@ -91,9 +91,6 @@
$aux_fields = $this->loadAuxiliaryFields($revision);
$comments = $revision->loadComments();
- $comments = array_merge(
- $this->getImplicitComments($revision, reset($diffs)),
- $comments);
$all_changesets = $changesets;
$inlines = $this->loadInlineComments(
@@ -111,22 +108,8 @@
mpull($comments, 'getAuthorPHID'));
foreach ($comments as $comment) {
- $metadata = $comment->getMetadata();
- $added_reviewers = idx(
- $metadata,
- DifferentialComment::METADATA_ADDED_REVIEWERS);
- if ($added_reviewers) {
- foreach ($added_reviewers as $phid) {
- $object_phids[] = $phid;
- }
- }
- $added_ccs = idx(
- $metadata,
- DifferentialComment::METADATA_ADDED_CCS);
- if ($added_ccs) {
- foreach ($added_ccs as $phid) {
- $object_phids[] = $phid;
- }
+ foreach ($comment->getRequiredHandlePHIDs() as $phid) {
+ $object_phids[] = $phid;
}
}
@@ -479,38 +462,6 @@
));
}
- private function getImplicitComments(
- DifferentialRevision $revision,
- DifferentialDiff $diff) {
-
- $author_phid = nonempty(
- $diff->getAuthorPHID(),
- $revision->getAuthorPHID());
-
- $template = new DifferentialComment();
- $template->setAuthorPHID($author_phid);
- $template->setRevisionID($revision->getID());
- $template->setDateCreated($revision->getDateCreated());
-
- $comments = array();
-
- if (strlen($revision->getSummary())) {
- $summary_comment = clone $template;
- $summary_comment->setContent($revision->getSummary());
- $summary_comment->setAction(DifferentialAction::ACTION_SUMMARIZE);
- $comments[] = $summary_comment;
- }
-
- if (strlen($revision->getTestPlan())) {
- $testplan_comment = clone $template;
- $testplan_comment->setContent($revision->getTestPlan());
- $testplan_comment->setAction(DifferentialAction::ACTION_TESTPLAN);
- $comments[] = $testplan_comment;
- }
-
- return $comments;
- }
-
private function getRevisionActions(DifferentialRevision $revision) {
$user = $this->getRequest()->getUser();
$viewer_phid = $user->getPHID();
diff --git a/src/applications/differential/editor/DifferentialCommentEditor.php b/src/applications/differential/editor/DifferentialCommentEditor.php
--- a/src/applications/differential/editor/DifferentialCommentEditor.php
+++ b/src/applications/differential/editor/DifferentialCommentEditor.php
@@ -566,7 +566,7 @@
$comment = id(new DifferentialComment())
->setAuthorPHID($actor_phid)
- ->setRevisionID($revision->getID())
+ ->setRevision($revision)
->setAction($action)
->setContent((string)$this->message)
->setMetadata($metadata);
diff --git a/src/applications/differential/editor/DifferentialRevisionEditor.php b/src/applications/differential/editor/DifferentialRevisionEditor.php
--- a/src/applications/differential/editor/DifferentialRevisionEditor.php
+++ b/src/applications/differential/editor/DifferentialRevisionEditor.php
@@ -823,10 +823,9 @@
private function createComment() {
- $revision_id = $this->revision->getID();
$comment = id(new DifferentialComment())
->setAuthorPHID($this->getActorPHID())
- ->setRevisionID($revision_id)
+ ->setRevision($this->revision)
->setContent($this->getComments())
->setAction(DifferentialAction::ACTION_UPDATE)
->setMetadata(
diff --git a/src/applications/differential/storage/DifferentialComment.php b/src/applications/differential/storage/DifferentialComment.php
--- a/src/applications/differential/storage/DifferentialComment.php
+++ b/src/applications/differential/storage/DifferentialComment.php
@@ -20,11 +20,39 @@
private $arbitraryDiffForFacebook;
+ public function setRevision(DifferentialRevision $revision) {
+ return $this->setRevisionID($revision->getID());
+ }
+
public function giveFacebookSomeArbitraryDiff(DifferentialDiff $diff) {
$this->arbitraryDiffForFacebook = $diff;
return $this;
}
+ public function getRequiredHandlePHIDs() {
+ $phids = array();
+
+ $metadata = $this->getMetadata();
+ $added_reviewers = idx(
+ $metadata,
+ self::METADATA_ADDED_REVIEWERS);
+ if ($added_reviewers) {
+ foreach ($added_reviewers as $phid) {
+ $phids[] = $phid;
+ }
+ }
+ $added_ccs = idx(
+ $metadata,
+ self::METADATA_ADDED_CCS);
+ if ($added_ccs) {
+ foreach ($added_ccs as $phid) {
+ $phids[] = $phid;
+ }
+ }
+
+ return $phids;
+ }
+
public function getConfiguration() {
return array(
self::CONFIG_SERIALIZATION => array(
@@ -42,16 +70,8 @@
return PhabricatorContentSource::newFromSerialized($this->contentSource);
}
-
public function getMarkupFieldKey($field) {
- if ($this->getID()) {
- return 'DC:'.$this->getID();
- }
-
- // The summary and test plan render as comments, but do not have IDs.
- // They are also mutable. Build keys using content hashes.
- $hash = PhabricatorHash::digest($this->getMarkupText($field));
- return 'DC:'.$hash;
+ return 'DC:'.$this->getID();
}
public function newMarkupEngine($field) {
@@ -70,18 +90,7 @@
}
public function shouldUseMarkupCache($field) {
- if ($this->getID()) {
- return true;
- }
-
- $action = $this->getAction();
- switch ($action) {
- case DifferentialAction::ACTION_SUMMARIZE:
- case DifferentialAction::ACTION_TESTPLAN:
- return true;
- }
-
- return false;
+ return (bool)$this->getID();
}
}
diff --git a/src/applications/differential/view/DifferentialRevisionDetailView.php b/src/applications/differential/view/DifferentialRevisionDetailView.php
--- a/src/applications/differential/view/DifferentialRevisionDetailView.php
+++ b/src/applications/differential/view/DifferentialRevisionDetailView.php
@@ -112,6 +112,28 @@
$properties->setHasKeyboardShortcuts(true);
$properties->setActionList($actions);
+ $properties->invokeWillRenderEvent();
+
+ if (strlen($revision->getSummary())) {
+ $properties->addSectionHeader(pht('Summary'));
+ $properties->addTextContent(
+ PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())->setContent(
+ $revision->getSummary()),
+ 'default',
+ $user));
+ }
+
+ if (strlen($revision->getTestPlan())) {
+ $properties->addSectionHeader(pht('Test Plan'));
+ $properties->addTextContent(
+ PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())->setContent(
+ $revision->getTestPlan()),
+ 'default',
+ $user));
+ }
+
$object_box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties);

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/hu/ge/d6q6i5lifnmynfzt
Default Alt Text
D7375.id16595.diff (7 KB)

Event Timeline