1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Adapt to style changes; fix performance bug when loading hunks for changesets.

This commit is contained in:
Manuel Klimek 2012-08-13 19:32:19 +00:00 committed by Manuel Klimek
parent 0ce886121c
commit 10773c5cb6
2 changed files with 21 additions and 14 deletions

View file

@ -152,6 +152,13 @@ final class DifferentialCommentMail extends DifferentialMail {
if ($inlines) {
$body[] = 'INLINE COMMENTS';
$changesets = $this->getChangesets();
if (PhabricatorEnv::getEnvConfig(
'metamta.differential.unified-comment-context', false)) {
foreach ($changesets as $changeset) {
$changeset->attachHunks($changeset->loadHunks());
}
}
foreach ($inlines as $inline) {
$changeset = $changesets[$inline->getChangesetID()];
if (!$changeset) {
@ -172,8 +179,6 @@ final class DifferentialCommentMail extends DifferentialMail {
} else {
$body[] = "================";
$body[] = "Comment at: " . $file . ":" . $range;
$changeset->attachHunks($changeset->loadHunks());
$body[] = $changeset->makeContextDiff($inline, 1);
$body[] = "----------------";

View file

@ -217,7 +217,7 @@ final class DifferentialChangeset extends DifferentialDAO {
public function makeContextDiff($inline, $add_context) {
$context = array();
$debug = False;
$debug = false;
if ($debug) {
$context[] = 'Inline: '.$inline->getIsNewFile().' '.
$inline->getLineNumber().' '.$inline->getLineLength();
@ -254,31 +254,33 @@ final class DifferentialChangeset extends DifferentialDAO {
$hunk_offset = array( "-" => NULL, "+" => NULL );
$hunk_last = array( "-" => NULL, "+" => NULL );
foreach (explode("\n", $hunk->getChanges()) as $line) {
$inCommon = strncmp($line, " ", 1) === 0;
$inOld = strncmp($line, "-", 1) === 0 || $inCommon;
$inNew = strncmp($line, "+", 1) === 0 || $inCommon;
$inSelected = strncmp($line, $prefix, 1) === 0;
$skip = !$inSelected && !$inCommon;
$in_common = strncmp($line, " ", 1) === 0;
$in_old = strncmp($line, "-", 1) === 0 || $in_common;
$in_new = strncmp($line, "+", 1) === 0 || $in_common;
$in_selected = strncmp($line, $prefix, 1) === 0;
$skip = !$in_selected && !$in_common;
if ($hunk_pos[$prefix] <= $end) {
if ($start <= $hunk_pos[$prefix]) {
if (!$skip || ($hunk_pos[$prefix] != $start &&
$hunk_pos[$prefix] != $end)) {
if ($inOld) {
if ($hunk_offset["-"] === NULL)
if ($in_old) {
if ($hunk_offset["-"] === NULL) {
$hunk_offset["-"] = $hunk_pos["-"];
}
$hunk_last["-"] = $hunk_pos["-"];
}
if ($inNew) {
if ($hunk_offset["+"] === NULL)
if ($in_new) {
if ($hunk_offset["+"] === NULL) {
$hunk_offset["+"] = $hunk_pos["+"];
}
$hunk_last["+"] = $hunk_pos["+"];
}
$hunk_content[] = $line;
}
}
if ($inOld) ++$hunk_pos["-"];
if ($inNew) ++$hunk_pos["+"];
if ($in_old) { ++$hunk_pos["-"]; }
if ($in_new) { ++$hunk_pos["+"]; }
}
}
if ($hunk_offset["-"] !== NULL || $hunk_offset["+"] !== NULL) {