[file-history] file path is the same in folder history, so no need to use special FileHistoryUi methods

This commit is contained in:
Julia Beliaeva
2018-10-02 21:16:24 +03:00
parent 4029927bf3
commit 24ba5a9ebf
3 changed files with 9 additions and 9 deletions
@@ -43,8 +43,6 @@ import java.util.*;
import static com.intellij.util.ObjectUtils.notNull;
import static com.intellij.util.ObjectUtils.notNull;
public class FileHistoryUi extends AbstractVcsLogUi {
@NotNull private static final String HELP_ID = "reference.versionControl.toolwindow.history";
@NotNull private final FilePath myPath;
@@ -150,7 +148,7 @@ public class FileHistoryUi extends AbstractVcsLogUi {
}
@NotNull
public List<Change> collectRelevantChanges(@NotNull VcsFullCommitDetails details) {
List<Change> collectRelevantChanges(@NotNull VcsFullCommitDetails details) {
FilePath filePath = getPathInCommit(details.getId());
if (filePath == null) return ContainerUtil.emptyList();
return FileHistoryUtil.collectRelevantChanges(details,
@@ -45,8 +45,8 @@ public class FileHistoryUtil {
}
@NotNull
static List<Change> collectRelevantChanges(@NotNull VcsFullCommitDetails details,
@NotNull Condition<? super Change> isRelevant) {
public static List<Change> collectRelevantChanges(@NotNull VcsFullCommitDetails details,
@NotNull Condition<? super Change> isRelevant) {
List<Change> changes = filter(details.getChanges(), isRelevant);
if (!changes.isEmpty()) return changes;
if (details.getParents().size() > 1) {
@@ -64,7 +64,7 @@ public class FileHistoryUtil {
return file.equals(revision.getFile());
}
static boolean affectsDirectory(@NotNull Change change, @NotNull FilePath directory) {
public static boolean affectsDirectory(@NotNull Change change, @NotNull FilePath directory) {
FilePath file = notNull(chooseNotNull(change.getAfterRevision(), change.getBeforeRevision())).getFile();
return VfsUtilCore.isAncestor(directory.getIOFile(), file.getIOFile(), false);
}
@@ -19,12 +19,14 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.AnActionExtensionProvider
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.ui.MessageType
import com.intellij.openapi.util.Condition
import com.intellij.openapi.vcs.VcsDataKeys
import com.intellij.openapi.vcs.history.VcsDiffUtil
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier
import com.intellij.util.ObjectUtils.notNull
import com.intellij.util.containers.ContainerUtil
import com.intellij.vcs.log.VcsLog
import com.intellij.vcs.log.history.FileHistoryUtil
import com.intellij.vcs.log.ui.VcsLogInternalDataKeys
import com.intellij.vcs.log.statistics.VcsLogUsageTriggerCollector
import java.awt.event.KeyEvent
@@ -77,8 +79,7 @@ class CompareRevisionsFromHistoryActionProvider : AnActionExtensionProvider {
val newestId = commits[0]
val olderId = commits[1]
notNull(handler).showDiff(olderId.root, ui.getPathInCommit(olderId.hash), olderId.hash,
ui.getPathInCommit(newestId.hash), newestId.hash)
notNull(handler).showDiff(olderId.root, filePath, olderId.hash, filePath, newestId.hash)
return
}
@@ -87,7 +88,8 @@ class CompareRevisionsFromHistoryActionProvider : AnActionExtensionProvider {
val commitIds = ContainerUtil.map(commits) { c -> ui.logData.getCommitIndex(c.hash, c.root) }
ui.logData.commitDetailsGetter.loadCommitsData(commitIds, { details ->
val detail = notNull(ContainerUtil.getFirstItem(details))
val changes = ui.collectRelevantChanges(detail)
val changes = FileHistoryUtil.collectRelevantChanges(detail,
Condition { change -> FileHistoryUtil.affectsDirectory(change, filePath) })
VcsDiffUtil.showChangesDialog(project, "Changes in " + detail.id.toShortString() + " for " + filePath.name,
ContainerUtil.newArrayList(changes))
}, { t -> VcsBalloonProblemNotifier.showOverChangesView(project, "Could not load selected commits: " + t.message, MessageType.ERROR) },