IDEA-193195 vcs: fix "Compare with Local" for renamed files

This commit is contained in:
Aleksey Pivovarov
2018-06-04 14:36:08 +03:00
parent 79b830e7e8
commit 3e0e704bdb
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
@@ -79,9 +80,18 @@ public class ShowDiffWithLocalAction extends AnAction implements DumbAware, AnAc
@Nullable
private Change getChangeWithLocal(@NotNull Change c) {
ContentRevision revision = myUseBeforeVersion ? c.getBeforeRevision() : c.getAfterRevision();
ContentRevision otherRevision = myUseBeforeVersion ? c.getAfterRevision() : c.getBeforeRevision();
if (!isValidRevision(revision)) return null;
ContentRevision contentRevision = CurrentContentRevision.create(revision.getFile());
FilePath filePath = revision.getFile();
if (filePath.getVirtualFile() == null && otherRevision != null) {
FilePath otherFile = otherRevision.getFile();
if (otherFile.getVirtualFile() != null) {
filePath = otherFile;
}
}
ContentRevision contentRevision = CurrentContentRevision.create(filePath);
return new Change(revision, contentRevision);
}