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

Condense renames in Differential ToC

Summary: It's currently quite confusing.

Test Plan:
  lang=diff
  diff --git a/bin/config b/bin/x
  similarity index 100%
  rename from bin/config
  rename to bin/x
  diff --git a/bin/aphlict b/bin/y/aphlict
  similarity index 100%
  rename from bin/aphlict
  rename to bin/y/aphlict
  diff --git a/bin/diviner b/scripts/z
  similarity index 100%
  rename from bin/diviner
  rename to scripts/z

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Differential Revision: https://secure.phabricator.com/D5708
This commit is contained in:
Jakub Vrana 2013-04-16 11:02:04 -07:00
parent ef3d1150fc
commit ed02823eaf

View file

@ -82,8 +82,9 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
$type = $changeset->getChangeType();
$ftype = $changeset->getFileType();
$ref = idx($this->references, $id);
$link = $this->renderChangesetLink($changeset, $ref);
$display_file = $changeset->getDisplayFilename();
$meta = null;
if (DifferentialChangeType::isOldLocationChangeType($type)) {
$away = $changeset->getAwayPaths();
if (count($away) > 1) {
@ -99,19 +100,26 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
$meta = phutil_implode_html(phutil_tag('br'), $meta);
} else {
if ($type == DifferentialChangeType::TYPE_MOVE_AWAY) {
$meta = pht('Moved to %s', reset($away));
$display_file = $this->renderRename(
$display_file,
reset($away),
"\xE2\x86\x92");
} else {
$meta = pht('Copied to %s', reset($away));
}
}
} else if ($type == DifferentialChangeType::TYPE_MOVE_HERE) {
$meta = pht('Moved from %s', $changeset->getOldFile());
$old_file = $changeset->getOldFile();
$display_file = $this->renderRename(
$display_file,
$old_file,
"\xE2\x86\x90");
} else if ($type == DifferentialChangeType::TYPE_COPY_HERE) {
$meta = pht('Copied from %s', $changeset->getOldFile());
} else {
$meta = null;
}
$link = $this->renderChangesetLink($changeset, $ref, $display_file);
$line_count = $changeset->getAffectedLineCount();
if ($line_count == 0) {
$lines = null;
@ -233,6 +241,38 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
$buttons);
}
private function renderRename($display_file, $other_file, $arrow) {
$old = explode('/', $display_file);
$new = explode('/', $other_file);
$start = count($old);
foreach ($old as $index => $part) {
if (!isset($new[$index]) || $part != $new[$index]) {
$start = $index;
break;
}
}
$end = count($old);
foreach (array_reverse($old) as $from_end => $part) {
$index = count($new) - $from_end - 1;
if (!isset($new[$index]) || $part != $new[$index]) {
$end = $from_end;
break;
}
}
$rename =
'{'.
implode('/', array_slice($old, $start, count($old) - $end - $start)).
' '.$arrow.' '.
implode('/', array_slice($new, $start, count($new) - $end - $start)).
'}';
array_splice($new, $start, count($new) - $end - $start, $rename);
return implode('/', $new);
}
private function renderCoverage(array $coverage, $file) {
$info = idx($coverage, $file);
if (!$info) {
@ -250,8 +290,10 @@ final class DifferentialDiffTableOfContentsView extends AphrontView {
}
private function renderChangesetLink(DifferentialChangeset $changeset, $ref) {
$display_file = $changeset->getDisplayFilename();
private function renderChangesetLink(
DifferentialChangeset $changeset,
$ref,
$display_file) {
return javelin_tag(
'a',