[vcs-log] add VcsLogProperty for determining whether log provider supports indexing, introduce registry key to enable it for Git

This commit is contained in:
Julia Beliaeva
2016-09-20 00:15:17 +03:00
parent f800b93721
commit 39ae38d5a0
4 changed files with 17 additions and 3 deletions
@@ -300,6 +300,8 @@ vcs.log.labels.redesign=false
vcs.log.labels.redesign.description=Show branch labels on the right with combined tag icons, do not display tag names, combine tracked branches, display detached heads with an exclamation mark
vcs.log.highlight.not.indexed=false
vcs.log.highlight.not.indexed.description=Highlight commits that are not indexed
vcs.log.index.git=false
vcs.log.index.git.description=Index all commits in Git repository for fast search
vcs.executable.validator.timeout.sec=60
vcs.unversioned.files.in.commit=true
@@ -27,6 +27,7 @@ public class VcsLogProperties {
}
@NotNull public static final VcsLogProperty<Boolean> LIGHTWEIGHT_BRANCHES = new VcsLogProperty<>(false);
@NotNull public static final VcsLogProperty<Boolean> SUPPORTS_INDEXING = new VcsLogProperty<>(false);
@NotNull
public static <T> T get(@NotNull VcsLogProvider provider, VcsLogProperty<T> property) {
@@ -86,7 +86,13 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable {
myProject = project;
myProviders = providers;
myFatalErrorsConsumer = fatalErrorsConsumer;
myRoots = providers.keySet();
myRoots = ContainerUtil.newLinkedHashSet();
for (Map.Entry<VirtualFile, VcsLogProvider> entry : providers.entrySet()) {
if (VcsLogProperties.get(entry.getValue(), VcsLogProperties.SUPPORTS_INDEXING)) {
myRoots.add(entry.getKey());
}
}
myUserRegistry = (VcsUserRegistryImpl)ServiceManager.getService(myProject, VcsUserRegistry.class);
@@ -194,12 +200,12 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable {
@Override
public synchronized boolean isIndexed(@NotNull VirtualFile root) {
return !myCommitsToIndex.containsKey(root) && myNumberOfTasks.get(root).get() == 0;
return myRoots.contains(root) && (!myCommitsToIndex.containsKey(root) && myNumberOfTasks.get(root).get() == 0);
}
@Override
public synchronized void markForIndexing(int index, @NotNull VirtualFile root) {
if (isIndexed(index)) return;
if (isIndexed(index) || !myRoots.contains(root)) return;
TIntHashSet set = myCommitsToIndex.get(root);
if (set == null) {
set = new TIntHashSet();
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Attachment;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ThrowableNotNullFunction;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsException;
@@ -518,12 +519,16 @@ public class GitLogProvider implements VcsLogProvider {
return currentBranchName;
}
@SuppressWarnings("unchecked")
@Nullable
@Override
public <T> T getPropertyValue(VcsLogProperties.VcsLogProperty<T> property) {
if (property == VcsLogProperties.LIGHTWEIGHT_BRANCHES) {
return (T)Boolean.TRUE;
}
else if (property == VcsLogProperties.SUPPORTS_INDEXING) {
return (T)Boolean.valueOf(Registry.is("vcs.log.index.git"));
}
return null;
}