1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Display link in Revision ToC for copied or moved files

Summary:
They are present in the document so there is not reason to omit the links to
them.
They sometimes contains changed lines so the link could be actualy useful.

Test Plan: Display ToC of revision with moved and copied files.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, nh

Differential Revision: https://secure.phabricator.com/D1412
This commit is contained in:
vrana 2012-01-15 22:43:54 -08:00
parent c7997e0a7c
commit f109342a7a

View file

@ -64,8 +64,40 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
$type = $changeset->getChangeType(); $type = $changeset->getChangeType();
$ftype = $changeset->getFileType(); $ftype = $changeset->getFileType();
if ($this->standaloneViewLink) {
$id = $changeset->getID();
if ($id) {
$vs_id = idx($this->vsMap, $id);
} else {
$vs_id = null;
}
$ref = $vs_id ? $id.'/'.$vs_id : $id;
$detail_uri = new PhutilURI($this->renderURI);
$detail_uri->setQueryParams(
array(
'ref' => $ref,
'whitespace' => $this->whitespace,
'revision_id' => $this->revisionID,
));
$link = phutil_render_tag(
'a',
array(
'href' => $detail_uri,
'target' => '_blank',
),
phutil_escape_html($display_file));
} else {
$link = phutil_render_tag(
'a',
array(
'href' => '#'.$changeset->getAnchorName(),
),
phutil_escape_html($display_file));
}
if (DifferentialChangeType::isOldLocationChangeType($type)) { if (DifferentialChangeType::isOldLocationChangeType($type)) {
$link = phutil_escape_html($display_file);
$away = $changeset->getAwayPaths(); $away = $changeset->getAwayPaths();
if (count($away) > 1) { if (count($away) > 1) {
$meta = array(); $meta = array();
@ -85,48 +117,12 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
$meta = 'Copied to '.phutil_escape_html(reset($away)); $meta = 'Copied to '.phutil_escape_html(reset($away));
} }
} }
} else if ($type == DifferentialChangeType::TYPE_MOVE_HERE) {
$meta = 'Moved from '.phutil_escape_html($changeset->getOldFile());
} else if ($type == DifferentialChangeType::TYPE_COPY_HERE) {
$meta = 'Copied from '.phutil_escape_html($changeset->getOldFile());
} else { } else {
$meta = null;
if ($this->standaloneViewLink) {
$id = $changeset->getID();
if ($id) {
$vs_id = idx($this->vsMap, $id);
} else {
$vs_id = null;
}
$ref = $vs_id ? $id.'/'.$vs_id : $id;
$detail_uri = new PhutilURI($this->renderURI);
$detail_uri->setQueryParams(
array(
'ref' => $ref,
'whitespace' => $this->whitespace,
'revision_id' => $this->revisionID,
));
$link = phutil_render_tag(
'a',
array(
'href' => $detail_uri,
'target' => '_blank',
),
phutil_escape_html($display_file));
} else {
$link = phutil_render_tag(
'a',
array(
'href' => '#'.$changeset->getAnchorName(),
),
phutil_escape_html($display_file));
}
if ($type == DifferentialChangeType::TYPE_MOVE_HERE) {
$meta = 'Moved from '.phutil_escape_html($changeset->getOldFile());
} else if ($type == DifferentialChangeType::TYPE_COPY_HERE) {
$meta = 'Copied from '.phutil_escape_html($changeset->getOldFile());
} else {
$meta = null;
}
} }
$line_count = $changeset->getAffectedLineCount(); $line_count = $changeset->getAffectedLineCount();