Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14011817
D10146.id24679.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10146.id24679.diff
View Options
diff --git a/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php b/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
--- a/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
+++ b/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
@@ -293,7 +293,7 @@
pht(
'Normally, inline comments in emails are shown with a file and '.
'line but without any diff context. Enabling this option adds '.
- 'diff context.')),
+ 'diff context and the comment thread.')),
);
}
diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php
--- a/src/applications/differential/editor/DifferentialTransactionEditor.php
+++ b/src/applications/differential/editor/DifferentialTransactionEditor.php
@@ -1277,6 +1277,38 @@
return $result;
}
+ protected function indentForMail(array $lines) {
+ $indented = array();
+ foreach ($lines as $line) {
+ $indented[] = '> '.$line;
+ }
+ return $indented;
+ }
+
+ protected function nestCommentHistory(
+ DifferentialTransactionComment $comment, array $comments_by_line_number,
+ array $users_by_phid) {
+
+ $nested = array();
+ $previous_comments = $comments_by_line_number[$comment->getChangesetID()]
+ [$comment->getLineNumber()];
+ foreach ($previous_comments as $previous_comment) {
+ if ($previous_comment->getID() >= $comment->getID())
+ break;
+ $nested = $this->indentForMail(
+ array_merge(
+ $nested,
+ explode("\n", $previous_comment->getContent())));
+ $user = idx($users_by_phid, $previous_comment->getAuthorPHID(), null);
+ if ($user) {
+ array_unshift($nested, $user->getUserName().' wrote:');
+ }
+ }
+
+ $nested = array_merge($nested, explode("\n", $comment->getContent()));
+ return implode("\n", $nested);
+ }
+
private function renderInlineCommentsForMail(
PhabricatorLiskDAO $object,
array $inlines) {
@@ -1285,9 +1317,12 @@
$show_context = PhabricatorEnv::getEnvConfig($context_key);
$changeset_ids = array();
+ $line_numbers_by_changeset = array();
foreach ($inlines as $inline) {
$id = $inline->getComment()->getChangesetID();
$changeset_ids[$id] = $id;
+ $line_numbers_by_changeset[$id][] =
+ $inline->getComment()->getLineNumber();
}
$changesets = id(new DifferentialChangesetQuery())
@@ -1302,6 +1337,26 @@
if ($show_context) {
$hunk_parser = new DifferentialHunkParser();
+ $queries = array();
+ foreach ($line_numbers_by_changeset as $id => $line_numbers) {
+ $queries[] = '(changesetID = '.$id.
+ ' AND (lineNumber = '.join(' OR lineNumber = ', $line_numbers).'))';
+ }
+ $all_comments = id(new DifferentialTransactionComment())->loadAllWhere(
+ '('.join(' OR ', $queries).') AND transactionPHID IS NOT NULL');
+ $comments_by_line_number = array();
+ foreach ($all_comments as $comment) {
+ $comments_by_line_number
+ [$comment->getChangesetID()]
+ [$comment->getLineNumber()]
+ [$comment->getID()] = $comment;
+ }
+ $author_phids = array_keys(mpull($all_comments, null, 'getAuthorPHID'));
+ $authors = id(new PhabricatorPeopleQuery())
+ ->setViewer($this->getActor())
+ ->withPHIDs($author_phids)
+ ->execute();
+ $authors_by_phid = mpull($authors, null, 'getPHID');
}
$result = array();
@@ -1336,8 +1391,8 @@
$comment->getLineLength(),
1);
$result[] = '----------------';
-
- $result[] = $inline_content;
+ $result[] = $this->nestCommentHistory(
+ $inline->getComment(), $comments_by_line_number, $authors_by_phid);
$result[] = null;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 2, 5:21 AM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6742415
Default Alt Text
D10146.id24679.diff (3 KB)
Attached To
Mode
D10146: Add an option to put comment context into emails.
Attached
Detach File
Event Timeline
Log In to Comment