Page MenuHomePhabricator

D12493.id29988.diff
No OneTemporary

D12493.id29988.diff

diff --git a/src/applications/differential/controller/DifferentialChangesetViewController.php b/src/applications/differential/controller/DifferentialChangesetViewController.php
--- a/src/applications/differential/controller/DifferentialChangesetViewController.php
+++ b/src/applications/differential/controller/DifferentialChangesetViewController.php
@@ -321,6 +321,8 @@
$id_map[$changeset->getID()] = $changeset->getID();
}
+ $move_here = DifferentialChangeType::TYPE_MOVE_HERE;
+
// Generate filename maps for older and newer comments. If we're briging an
// older comment forward in a diff-of-diffs, we want to put it on the left
// side of the screen, not the right side. Both sides are "new" files with
@@ -329,18 +331,31 @@
// to read left-to-right and old-to-new.
$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
@@ -378,17 +393,53 @@
// 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) {

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 12, 8:14 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7579640
Default Alt Text
D12493.id29988.diff (4 KB)

Event Timeline