diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexDataGetter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexDataGetter.java index 7d1780cfb814..a9e5885c38f1 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexDataGetter.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexDataGetter.java @@ -22,6 +22,9 @@ import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.StorageException; +import com.intellij.vcs.log.CommitId; +import com.intellij.vcs.log.Hash; +import com.intellij.vcs.log.data.VcsLogStorage; import com.intellij.vcs.log.impl.FatalErrorHandler; import com.intellij.vcsUtil.VcsUtil; import gnu.trove.TIntObjectHashMap; @@ -40,15 +43,18 @@ public class IndexDataGetter { @NotNull private final Project myProject; @NotNull private final Set myRoots; @NotNull private final VcsLogPersistentIndex.IndexStorage myIndexStorage; + @NotNull private final VcsLogStorage myLogStorage; @NotNull private final FatalErrorHandler myFatalErrorsConsumer; public IndexDataGetter(@NotNull Project project, @NotNull Set roots, - @NotNull VcsLogPersistentIndex.IndexStorage storage, + @NotNull VcsLogPersistentIndex.IndexStorage indexStorage, + @NotNull VcsLogStorage logStorage, @NotNull FatalErrorHandler fatalErrorsConsumer) { myProject = project; myRoots = roots; - myIndexStorage = storage; + myIndexStorage = indexStorage; + myLogStorage = logStorage; myFatalErrorsConsumer = fatalErrorsConsumer; } @@ -108,6 +114,25 @@ public class IndexDataGetter { return null; } + @NotNull + public List getParents(int index) { + try { + List parentsIndexes = myIndexStorage.parents.get(index); + if (parentsIndexes == null) return Collections.emptyList(); + List result = ContainerUtil.newArrayList(); + for (int parentIndex : parentsIndexes) { + CommitId id = myLogStorage.getCommitId(parentIndex); + if (id == null) return Collections.emptyList(); + result.add(id.getHash()); + } + return result; + } + catch (IOException e) { + myFatalErrorsConsumer.consume(this, e); + } + return Collections.emptyList(); + } + public class FileNamesData { @NotNull private final TIntObjectHashMap>> myCommitToPathAndChanges = new TIntObjectHashMap<>(); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexedDetails.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexedDetails.java index d4c4550c376d..90f7858f2257 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexedDetails.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexedDetails.java @@ -15,10 +15,13 @@ */ package com.intellij.vcs.log.data.index; +import com.intellij.vcs.log.Hash; import com.intellij.vcs.log.data.LoadingDetails; import com.intellij.vcs.log.data.VcsLogStorage; import org.jetbrains.annotations.NotNull; +import java.util.List; + public class IndexedDetails extends LoadingDetails { @NotNull private final IndexDataGetter myDataGetter; private final int myCommitIndex; @@ -56,4 +59,10 @@ public class IndexedDetails extends LoadingDetails { if (subjectEnd > 0) return fullMessage.substring(0, subjectEnd).replace("\n", " "); return fullMessage.replace("\n", " "); } + + @NotNull + @Override + public List getParents() { + return myDataGetter.getParents(myCommitIndex); + } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java index 40dfb3f6a812..bbd28c4f9619 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogPersistentIndex.java @@ -107,7 +107,7 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable { myIndexStorage = createIndexStorage(fatalErrorsConsumer, calcLogId(myProject, providers)); if (myIndexStorage != null) { - myDataGetter = new IndexDataGetter(myProject, myRoots, myIndexStorage, myFatalErrorsConsumer); + myDataGetter = new IndexDataGetter(myProject, myRoots, myIndexStorage, myStorage, myFatalErrorsConsumer); } else { myDataGetter = null;