mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[file-history] introduce a special filter for file history that anchors history to a specific revision
This commit is contained in:
@@ -218,14 +218,21 @@ internal class FileHistoryFilterer(logData: VcsLogData) : VcsLogFilterer {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getStructureFilter(filters: VcsLogFilterCollection) = filters.detailsFilters.singleOrNull() as? VcsLogStructureFilter
|
||||
|
||||
private fun getFilePath(filters: VcsLogFilterCollection): FilePath? {
|
||||
val filter = filters.detailsFilters.singleOrNull() as? VcsLogStructureFilter ?: return null
|
||||
val filter = getStructureFilter(filters) ?: return null
|
||||
return filter.files.singleOrNull()
|
||||
}
|
||||
|
||||
private fun getHash(filters: VcsLogFilterCollection): Hash? {
|
||||
val revisionFilter = filters.get(VcsLogFilterCollection.REVISION_FILTER) ?: return null
|
||||
return revisionFilter.heads.singleOrNull()?.hash
|
||||
val fileHistoryFilter = getStructureFilter(filters) as? VcsLogFileHistoryFilter
|
||||
if (fileHistoryFilter != null) {
|
||||
return fileHistoryFilter.hash
|
||||
}
|
||||
|
||||
val revisionFilter = filters.get(VcsLogFilterCollection.REVISION_FILTER)
|
||||
return revisionFilter?.heads?.singleOrNull()?.hash
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -236,7 +243,7 @@ internal class FileHistoryFilterer(logData: VcsLogData) : VcsLogFilterer {
|
||||
revision: Hash?,
|
||||
root: VirtualFile,
|
||||
showAllBranches: Boolean): VcsLogFilterCollection {
|
||||
val fileFilter = VcsLogStructureFilterImpl(setOf(path))
|
||||
val fileFilter = VcsLogFileHistoryFilter(path, revision)
|
||||
|
||||
if (revision != null) {
|
||||
val revisionFilter = VcsLogRevisionFilterImpl.fromCommit(CommitId(revision, root))
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.vcs.log.history;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.data.VcsLogStructureFilterImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class VcsLogFileHistoryFilter extends VcsLogStructureFilterImpl {
|
||||
@Nullable private final Hash myHash;
|
||||
|
||||
public VcsLogFileHistoryFilter(@NotNull FilePath file, @Nullable Hash hash) {
|
||||
super(Collections.singleton(file));
|
||||
myHash = hash;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Hash getHash() {
|
||||
return myHash;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user