diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 61ba698b9405..fddd22423c1b 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -298,6 +298,8 @@ vcs.log.keep.up.to.date=true vcs.log.keep.up.to.date.description=Load log on start after heavy tasks are completed and keep it up to date even when not visible 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.executable.validator.timeout.sec=60 vcs.unversioned.files.in.commit=true diff --git a/platform/vcs-log/impl/src/META-INF/vcs-log.xml b/platform/vcs-log/impl/src/META-INF/vcs-log.xml index 6c685b3b6664..6060cde93774 100644 --- a/platform/vcs-log/impl/src/META-INF/vcs-log.xml +++ b/platform/vcs-log/impl/src/META-INF/vcs-log.xml @@ -22,6 +22,7 @@ + diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogIndex.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogIndex.java index 53123504b77a..37e2f59a2a03 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogIndex.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/VcsLogIndex.java @@ -25,6 +25,8 @@ import java.util.Set; public interface VcsLogIndex { void scheduleIndex(boolean full); + boolean isIndexed(int commit); + void markForIndexing(int commit, @NotNull VirtualFile root); boolean canFilter(@NotNull List filters); 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 9a49398c88c8..1ba20eea4e50 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 @@ -166,6 +166,7 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable { } } + @Override public boolean isIndexed(int commit) { try { return myMessagesIndex.get(commit) != null && diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/IndexHighlighter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/IndexHighlighter.java new file mode 100644 index 000000000000..6c5488528857 --- /dev/null +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/IndexHighlighter.java @@ -0,0 +1,74 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.vcs.log.ui; + +import com.intellij.openapi.util.registry.Registry; +import com.intellij.ui.JBColor; +import com.intellij.vcs.log.*; +import com.intellij.vcs.log.data.VcsLogData; +import com.intellij.vcs.log.data.index.VcsLogIndex; +import org.jetbrains.annotations.NotNull; + +public class IndexHighlighter implements VcsLogHighlighter { + public static final JBColor NOT_INDEXED_COMMIT_FOREGROUND = JBColor.BLUE; + @NotNull private final VcsLogData myLogData; + + public IndexHighlighter(@NotNull VcsLogData logData) { + myLogData = logData; + } + + @NotNull + @Override + public VcsCommitStyle getStyle(@NotNull VcsShortCommitDetails details, boolean isSelected) { + if (isSelected || !Registry.is("vcs.log.highlight.not.indexed")) return VcsCommitStyle.DEFAULT; + VcsLogIndex index = myLogData.getIndex(); + if (!index.isIndexed(myLogData.getCommitIndex(details.getId(), details.getRoot()))) { + return VcsCommitStyleFactory.foreground(NOT_INDEXED_COMMIT_FOREGROUND); + } + return VcsCommitStyle.DEFAULT; + } + + @Override + public void update(@NotNull VcsLogDataPack dataPack, boolean refreshHappened) { + } + + public static class Factory implements VcsLogHighlighterFactory { + @NotNull private static final String ID = "INDEXED_COMMITS"; + + @NotNull + @Override + public VcsLogHighlighter createHighlighter(@NotNull VcsLogData logData, @NotNull VcsLogUi logUi) { + return new IndexHighlighter(logData); + } + + @NotNull + @Override + public String getId() { + return ID; + } + + @NotNull + @Override + public String getTitle() { + return "Indexed Commits"; + } + + @Override + public boolean showMenuItem() { + return false; + } + } +} diff --git a/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VisiblePackBuilderTest.kt b/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VisiblePackBuilderTest.kt index a9dd2a5b29fb..90ac52c5b39b 100644 --- a/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VisiblePackBuilderTest.kt +++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VisiblePackBuilderTest.kt @@ -248,6 +248,10 @@ class VisiblePackBuilderTest { } class EmptyIndex : VcsLogIndex { + override fun isIndexed(commit: Int): Boolean { + return false + } + override fun canFilter(filters: MutableList): Boolean { return false }