diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 285a67deba..46bb0209e3 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -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', diff --git a/src/applications/differential/controller/DifferentialChangesetViewController.php b/src/applications/differential/controller/DifferentialChangesetViewController.php index 01a1ff6de6..af9eeea505 100644 --- a/src/applications/differential/controller/DifferentialChangesetViewController.php +++ b/src/applications/differential/controller/DifferentialChangesetViewController.php @@ -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) {