[vcs-log] highlighter for unindexed commits

This commit is contained in:
Julia Beliaeva
2016-09-20 00:15:17 +03:00
parent 905690d6fb
commit cd97ee20f2
6 changed files with 84 additions and 0 deletions
@@ -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
@@ -22,6 +22,7 @@
<logHighlighterFactory implementation="com.intellij.vcs.log.ui.MyCommitsHighlighter$Factory"/>
<logHighlighterFactory implementation="com.intellij.vcs.log.ui.MergeCommitsHighlighter$Factory"/>
<logHighlighterFactory implementation="com.intellij.vcs.log.ui.CurrentBranchHighlighter$Factory"/>
<logHighlighterFactory implementation="com.intellij.vcs.log.ui.IndexHighlighter$Factory"/>
<postStartupActivity implementation="com.intellij.vcs.log.impl.VcsProjectLog$InitLogStartupActivity"/>
</extensions>
@@ -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<VcsLogDetailsFilter> filters);
@@ -166,6 +166,7 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable {
}
}
@Override
public boolean isIndexed(int commit) {
try {
return myMessagesIndex.get(commit) != null &&
@@ -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;
}
}
}
@@ -248,6 +248,10 @@ class VisiblePackBuilderTest {
}
class EmptyIndex : VcsLogIndex {
override fun isIndexed(commit: Int): Boolean {
return false
}
override fun canFilter(filters: MutableList<VcsLogDetailsFilter>): Boolean {
return false
}