use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class AnnotateToggleAction method computeBgColors.
@Nullable
private static Couple<Map<VcsRevisionNumber, Color>> computeBgColors(@NotNull FileAnnotation fileAnnotation, @NotNull Editor editor) {
Map<VcsRevisionNumber, Color> commitOrderColors = new HashMap<>();
Map<VcsRevisionNumber, Color> commitAuthorColors = new HashMap<>();
EditorColorsScheme colorScheme = editor.getColorsScheme();
AnnotationsSettings settings = AnnotationsSettings.getInstance();
List<Color> authorsColorPalette = settings.getAuthorsColors(colorScheme);
List<Color> orderedColorPalette = settings.getOrderedColors(colorScheme);
FileAnnotation.AuthorsMappingProvider authorsMappingProvider = fileAnnotation.getAuthorsMappingProvider();
if (authorsMappingProvider != null) {
Map<VcsRevisionNumber, String> authorsMap = authorsMappingProvider.getAuthors();
Map<String, Color> authorColors = new HashMap<>();
for (String author : ContainerUtil.sorted(authorsMap.values(), Comparing::compare)) {
int index = authorColors.size();
Color color = authorsColorPalette.get(index % authorsColorPalette.size());
authorColors.put(author, color);
}
for (Map.Entry<VcsRevisionNumber, String> entry : authorsMap.entrySet()) {
VcsRevisionNumber revision = entry.getKey();
String author = entry.getValue();
Color color = authorColors.get(author);
commitAuthorColors.put(revision, color);
}
}
FileAnnotation.RevisionsOrderProvider revisionsOrderProvider = fileAnnotation.getRevisionsOrderProvider();
if (revisionsOrderProvider != null) {
List<List<VcsRevisionNumber>> orderedRevisions = revisionsOrderProvider.getOrderedRevisions();
int revisionsCount = orderedRevisions.size();
for (int index = 0; index < revisionsCount; index++) {
Color color = orderedColorPalette.get(orderedColorPalette.size() * index / revisionsCount);
for (VcsRevisionNumber number : orderedRevisions.get(index)) {
commitOrderColors.put(number, color);
}
}
}
return Couple.of(commitOrderColors.size() > 1 ? commitOrderColors : null, commitAuthorColors.size() > 1 ? commitAuthorColors : null);
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class AnnotateToggleAction method computeLineNumbers.
@Nullable
private static Map<VcsRevisionNumber, Integer> computeLineNumbers(@NotNull FileAnnotation fileAnnotation) {
final Map<VcsRevisionNumber, Integer> numbers = new HashMap<>();
final List<VcsFileRevision> fileRevisionList = fileAnnotation.getRevisions();
if (fileRevisionList != null) {
int size = fileRevisionList.size();
for (int i = 0; i < size; i++) {
VcsFileRevision revision = fileRevisionList.get(i);
final VcsRevisionNumber number = revision.getRevisionNumber();
numbers.put(number, size - i);
}
}
return numbers.size() < 2 ? null : numbers;
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class ContentRevisionCache method getOrLoadCurrentAsBytes.
public static Pair<VcsRevisionNumber, byte[]> getOrLoadCurrentAsBytes(final Project project, FilePath path, @NotNull VcsKey vcsKey, final CurrentRevisionProvider loader) throws VcsException, IOException {
ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(project).getContentRevisionCache();
VcsRevisionNumber currentRevision;
Pair<VcsRevisionNumber, byte[]> loaded;
while (true) {
currentRevision = putIntoCurrentCache(cache, path, vcsKey, loader);
final byte[] cachedCurrent = cache.getBytes(path, currentRevision, vcsKey, UniqueType.REPOSITORY_CONTENT);
if (cachedCurrent != null) {
return Pair.create(currentRevision, cachedCurrent);
}
checkLocalFileSize(path);
loaded = loader.get();
if (loaded.getFirst().equals(currentRevision))
break;
}
cache.put(path, currentRevision, vcsKey, UniqueType.REPOSITORY_CONTENT, loaded.getSecond());
return loaded;
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class ContentRevisionCache method putIntoCurrentCache.
private static VcsRevisionNumber putIntoCurrentCache(final ContentRevisionCache cache, FilePath path, @NotNull VcsKey vcsKey, final CurrentRevisionProvider loader) throws VcsException, IOException {
VcsRevisionNumber loadedRevisionNumber;
Pair<VcsRevisionNumber, Long> currentRevision;
while (true) {
loadedRevisionNumber = loader.getCurrentRevision();
currentRevision = cache.getCurrent(path, vcsKey);
if (loadedRevisionNumber.equals(currentRevision.getFirst()))
return loadedRevisionNumber;
if (cache.putCurrent(path, loadedRevisionNumber, vcsKey, currentRevision.getSecond())) {
return loadedRevisionNumber;
}
}
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class FileAnnotation method createDefaultAuthorsMappingProvider.
@Nullable
private static AuthorsMappingProvider createDefaultAuthorsMappingProvider(@NotNull FileAnnotation annotation) {
List<VcsFileRevision> revisions = annotation.getRevisions();
if (revisions == null)
return null;
Map<VcsRevisionNumber, String> authorsMapping = new HashMap<>();
for (VcsFileRevision revision : revisions) {
String author = revision.getAuthor();
if (author != null)
authorsMapping.put(revision.getRevisionNumber(), author);
}
return () -> authorsMapping;
}
Aggregations