From 1e2e154c7bbcccf0fdf89df7db807e38870b8928 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Wed, 12 Apr 2017 21:58:08 +0300 Subject: [PATCH] [file-history] use VcsLogDiffHandler for diff with local in file history This fixes directory diff IDEA-171150. --- .../ShowDiffWithLocalFromHistoryAction.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/history/ShowDiffWithLocalFromHistoryAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/history/ShowDiffWithLocalFromHistoryAction.java index 9705212778a9..3fa1861d1131 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/history/ShowDiffWithLocalFromHistoryAction.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/history/ShowDiffWithLocalFromHistoryAction.java @@ -20,30 +20,29 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsDataKeys; import com.intellij.openapi.vcs.changes.ChangeListManager; -import com.intellij.openapi.vcs.history.CurrentRevision; -import com.intellij.openapi.vcs.history.StandardDiffFromHistoryHandler; -import com.intellij.openapi.vcs.history.VcsFileRevision; -import com.intellij.openapi.vcs.history.VcsRevisionNumber; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.vcs.log.CommitId; import com.intellij.vcs.log.VcsFullCommitDetails; +import com.intellij.vcs.log.VcsLogDiffHandler; import com.intellij.vcs.log.history.FileHistoryUi; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static com.intellij.util.ObjectUtils.notNull; +import java.util.List; public class ShowDiffWithLocalFromHistoryAction extends FileHistorySingleCommitAction { @Override protected boolean isEnabled(@NotNull FileHistoryUi ui, @Nullable VcsFullCommitDetails detail, @NotNull AnActionEvent e) { FilePath filePath = e.getData(VcsDataKeys.FILE_PATH); - if (filePath == null || filePath.isDirectory() || filePath.getVirtualFile() == null) { - // currently not working for directories, to be fixed later + if (filePath == null || filePath.getVirtualFile() == null) { return false; } - if (detail != null) { - VcsFileRevision fileRevision = ui.createRevision(detail); - if (fileRevision == null) return false; + List commits = ui.getVcsLog().getSelectedCommits(); + if (filePath.isDirectory()) { + VcsLogDiffHandler handler = ui.getLogData().getLogProvider(commits.get(0).getRoot()).getDiffHandler(); + if (handler == null) return false; } return true; @@ -57,11 +56,11 @@ public class ShowDiffWithLocalFromHistoryAction extends FileHistorySingleCommitA if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return; FilePath path = e.getRequiredData(VcsDataKeys.FILE_PATH); - VcsFileRevision revision = ui.createRevision(detail); - if (revision != null) { - StandardDiffFromHistoryHandler handler = new StandardDiffFromHistoryHandler(); - handler.showDiffForTwo(project, path, revision, new CurrentRevision(notNull(path.getVirtualFile()), VcsRevisionNumber.NULL)); + VirtualFile root = detail.getRoot(); + VcsLogDiffHandler handler = ui.getLogData().getLogProvider(root).getDiffHandler(); + if (handler != null) { + handler.showDiffWithLocal(root, ui.getPath(detail), detail.getId(), path); } } }