mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[file-history] simplify VcsHistoryCache#editCached
GitOrigin-RevId: 518c56bcb34efe6dcba3783542605ba083a85cd9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
88f98a283a
commit
27bdf3dadd
@@ -8,7 +8,6 @@ import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.intellij.openapi.vcs.VcsKey
|
||||
import java.io.Serializable
|
||||
import java.util.function.Consumer
|
||||
|
||||
class VcsHistoryCache {
|
||||
private val historyCache: Cache<HistoryCacheBaseKey, CachedHistory>
|
||||
@@ -39,11 +38,10 @@ class VcsHistoryCache {
|
||||
return factory.createFromCachedData(customData, cachedHistory.revisions, cachedHistory.path, cachedHistory.currentRevision)
|
||||
}
|
||||
|
||||
fun editCached(filePath: FilePath, vcsKey: VcsKey, consumer: Consumer<in List<VcsFileRevision>>) {
|
||||
fun getRevisions(filePath: FilePath, vcsKey: VcsKey): List<VcsFileRevision> {
|
||||
val cachedHistory = historyCache.getIfPresent(HistoryCacheBaseKey(filePath, vcsKey))
|
||||
if (cachedHistory != null) {
|
||||
consumer.accept(cachedHistory.revisions)
|
||||
}
|
||||
if (cachedHistory == null) return emptyList()
|
||||
return cachedHistory.revisions
|
||||
}
|
||||
|
||||
fun clearHistory() {
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.svn.SvnVcs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.idea.svn.SvnBundle.messagePointer;
|
||||
|
||||
public class SvnEditCommitMessageFromFileHistoryAction extends DumbAwareAction {
|
||||
@@ -51,17 +53,17 @@ public class SvnEditCommitMessageFromFileHistoryAction extends DumbAwareAction {
|
||||
if (listener != null) {
|
||||
listener.consume(newMessage);
|
||||
}
|
||||
ProjectLevelVcsManager.getInstance(project).getVcsHistoryCache()
|
||||
.editCached(VcsUtil.getFilePath(revisionVirtualFile), vcsKey, revisions -> {
|
||||
for (VcsFileRevision fileRevision : revisions) {
|
||||
if (!(fileRevision instanceof SvnFileRevision)) continue;
|
||||
if (((SvnFileRevision)fileRevision).getRevision().getNumber() ==
|
||||
svnFileRevision.getRevision().getNumber()) {
|
||||
((SvnFileRevision)fileRevision).setCommitMessage(newMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
List<VcsFileRevision> revisions =
|
||||
ProjectLevelVcsManager.getInstance(project).getVcsHistoryCache()
|
||||
.getRevisions(VcsUtil.getFilePath(revisionVirtualFile), vcsKey);
|
||||
for (VcsFileRevision fileRevision : revisions) {
|
||||
if (!(fileRevision instanceof SvnFileRevision)) continue;
|
||||
if (((SvnFileRevision)fileRevision).getRevision().getNumber() ==
|
||||
svnFileRevision.getRevision().getNumber()) {
|
||||
((SvnFileRevision)fileRevision).setCommitMessage(newMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user