mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Track ghostly inlines across file moves
Summary: Ref T7447. Ref T7870. - Forward: When rendering some file "B" which was moved from "A", port ghosts for both "A" and "B" to it. - Backward: When porting a comment on "X" which was moved from some "Y", allow it to port to a file named "Y" if it can't find a file named "X". Test Plan: Before: {F377809} After: {F377806} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7447, T7870 Differential Revision: https://secure.phabricator.com/D12493
This commit is contained in:
parent
c596c358db
commit
8c39885076
2 changed files with 66 additions and 15 deletions
|
@ -58,7 +58,7 @@ return array(
|
|||
'rsrc/css/application/differential/add-comment.css' => 'c47f8c40',
|
||||
'rsrc/css/application/differential/changeset-view.css' => 'e19cfd6e',
|
||||
'rsrc/css/application/differential/core.css' => '7ac3cabc',
|
||||
'rsrc/css/application/differential/phui-inline-comment.css' => 'b7860d00',
|
||||
'rsrc/css/application/differential/phui-inline-comment.css' => '7adedadb',
|
||||
'rsrc/css/application/differential/results-table.css' => '181aa9d9',
|
||||
'rsrc/css/application/differential/revision-comment.css' => '024dda6b',
|
||||
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
|
||||
|
@ -797,7 +797,7 @@ return array(
|
|||
'phui-image-mask-css' => '5a8b09c8',
|
||||
'phui-info-panel-css' => '27ea50a1',
|
||||
'phui-info-view-css' => 'c6f0aef8',
|
||||
'phui-inline-comment-view-css' => 'b7860d00',
|
||||
'phui-inline-comment-view-css' => '7adedadb',
|
||||
'phui-list-view-css' => '2e25ebfb',
|
||||
'phui-object-box-css' => '7d160002',
|
||||
'phui-object-item-list-view-css' => '9db65899',
|
||||
|
|
|
@ -328,20 +328,35 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
|||
// is a better target conceptually for users because it's more consistent
|
||||
// with the rest of the UI, which shows old information on the left and
|
||||
// new information on the right.
|
||||
$move_here = DifferentialChangeType::TYPE_MOVE_HERE;
|
||||
|
||||
$name_map_old = array();
|
||||
$name_map_new = array();
|
||||
$move_map = array();
|
||||
foreach ($all as $changeset) {
|
||||
$filename = $changeset->getFilename();
|
||||
$changeset_id = $changeset->getID();
|
||||
|
||||
// We update the old map only if we don't already have an entry (oldest
|
||||
// changeset persists).
|
||||
if (empty($name_map_old[$filename])) {
|
||||
$name_map_old[$filename] = $changeset_id;
|
||||
$filenames = array();
|
||||
$filenames[] = $changeset->getFilename();
|
||||
|
||||
// If this is the target of a move, also map comments on the old filename
|
||||
// to this changeset.
|
||||
if ($changeset->getChangeType() == $move_here) {
|
||||
$old_file = $changeset->getOldFile();
|
||||
$filenames[] = $old_file;
|
||||
$move_map[$changeset_id][$old_file] = true;
|
||||
}
|
||||
|
||||
// We always update the new map (newest changeset overwrites).
|
||||
$name_map_new[$changeset->getFilename()] = $changeset_id;
|
||||
foreach ($filenames as $filename) {
|
||||
// We update the old map only if we don't already have an entry (oldest
|
||||
// changeset persists).
|
||||
if (empty($name_map_old[$filename])) {
|
||||
$name_map_old[$filename] = $changeset_id;
|
||||
}
|
||||
|
||||
// We always update the new map (newest changeset overwrites).
|
||||
$name_map_new[$changeset->getFilename()] = $changeset_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the smallest "new" changeset ID. We'll consider everything
|
||||
|
@ -379,17 +394,53 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
|||
// This changeset is on a file with the same name as the current
|
||||
// changeset, so we're going to port it forward or backward.
|
||||
$target_id = $name_map[$filename];
|
||||
|
||||
$is_move = isset($move_map[$target_id][$filename]);
|
||||
if ($is_new) {
|
||||
$reason = pht(
|
||||
'This comment was made on a file with the same name, but '.
|
||||
'in a newer diff.');
|
||||
if ($is_move) {
|
||||
$reason = pht(
|
||||
'This comment was made on a file with the same name as the '.
|
||||
'file this file was moved from, but in a newer diff.');
|
||||
} else {
|
||||
$reason = pht(
|
||||
'This comment was made on a file with the same name, but '.
|
||||
'in a newer diff.');
|
||||
}
|
||||
} else {
|
||||
$reason = pht(
|
||||
'This comment was made on a file with the same name, but '.
|
||||
'in an older diff.');
|
||||
if ($is_move) {
|
||||
$reason = pht(
|
||||
'This comment was made on a file with the same name as the '.
|
||||
'file this file was moved from, but in an older diff.');
|
||||
} else {
|
||||
$reason = pht(
|
||||
'This comment was made on a file with the same name, but '.
|
||||
'in an older diff.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we didn't find a target and this change is the target of a move,
|
||||
// look for a match against the old filename.
|
||||
if (!$target_id) {
|
||||
if ($changeset->getChangeType() == $move_here) {
|
||||
$filename = $changeset->getOldFile();
|
||||
if (isset($name_map[$filename])) {
|
||||
$target_id = $name_map[$filename];
|
||||
if ($is_new) {
|
||||
$reason = pht(
|
||||
'This comment was made on a file which this file was moved '.
|
||||
'to, but in a newer diff.');
|
||||
} else {
|
||||
$reason = pht(
|
||||
'This comment was made on a file which this file was moved '.
|
||||
'to, but in an older diff.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we found a changeset to port this comment to, bring it forward
|
||||
// or backward and mark it.
|
||||
if ($target_id) {
|
||||
|
|
Loading…
Reference in a new issue