mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] indexed details can retrieve parents
This commit is contained in:
committed by
Julia Beliaeva
parent
550127ab25
commit
0f46a77a1c
@@ -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<VirtualFile> myRoots;
|
||||
@NotNull private final VcsLogPersistentIndex.IndexStorage myIndexStorage;
|
||||
@NotNull private final VcsLogStorage myLogStorage;
|
||||
@NotNull private final FatalErrorHandler myFatalErrorsConsumer;
|
||||
|
||||
public IndexDataGetter(@NotNull Project project,
|
||||
@NotNull Set<VirtualFile> 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<Hash> getParents(int index) {
|
||||
try {
|
||||
List<Integer> parentsIndexes = myIndexStorage.parents.get(index);
|
||||
if (parentsIndexes == null) return Collections.emptyList();
|
||||
List<Hash> 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<Map<FilePath, Map<Integer, VcsLogPathsIndex.ChangeData>>> myCommitToPathAndChanges =
|
||||
new TIntObjectHashMap<>();
|
||||
|
||||
@@ -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<Hash> getParents() {
|
||||
return myDataGetter.getParents(myCommitIndex);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user