mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] move "Show in Git Log" action to the vcs.log.impl module
GitOrigin-RevId: c09d78a8f5ceed3f42c29183c5bdd6276808ab4c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
518ad43458
commit
f4ffae1199
@@ -95,6 +95,8 @@ action.Vcs.Log.CompareRevisions.text=Compare Versions
|
||||
action.Vcs.Log.CompareRevisions.description=Compare selected versions
|
||||
action.Vcs.Log.ResumeIndexing.text=Resume Indexing
|
||||
action.Vcs.Log.ResumeIndexing.description=Indexing was paused as it took longer than expected. Resume.
|
||||
action.Vcs.Log.SelectInLog.text=Show in Vcs Log
|
||||
action.Vcs.Log.SelectInLog.text.template=Show in {0} Log
|
||||
group.Vcs.Log.PresentationSettings.text=View Options
|
||||
group.Vcs.Log.PresentationSettings.description=Configure presentation of the Log
|
||||
group.Vcs.Log.ChangesBrowser.PresentationSettings.text=View Options
|
||||
|
||||
@@ -157,6 +157,9 @@
|
||||
<action class="com.intellij.vcs.log.ui.actions.InvalidateVcsLogCaches" id="Vcs.Log.InvalidateCaches" internal="true"/>
|
||||
<action class="com.intellij.vcs.log.ui.actions.CheckSelectedCommits" id="Vcs.Log.CheckSelectedCommitsIndexData" internal="true"/>
|
||||
<action class="com.intellij.vcs.log.ui.actions.CheckOldCommits" id="Vcs.Log.CheckFirstCommitsIndexData" internal="true"/>
|
||||
<action class="com.intellij.vcs.log.ui.actions.ShowCommitInLogAction" id="Vcs.Log.SelectInLog">
|
||||
<add-to-group group-id="VcsSelectionHistoryDialog.Popup" anchor="after" relative-to-action="Vcs.CopyRevisionNumberAction"/>
|
||||
</action>
|
||||
</group>
|
||||
|
||||
<group id="Vcs.Log.PresentationSettings" class="com.intellij.vcs.log.ui.actions.VcsLogToolbarPopupActionGroup"
|
||||
@@ -241,6 +244,7 @@
|
||||
<reference ref="Diff.ShowStandaloneDiff"/>
|
||||
<reference id="Vcs.Log.ShowAllAffected"/>
|
||||
<reference id="Vcs.Log.AnnotateRevisionAction"/>
|
||||
<reference id="Vcs.Log.SelectInLog"/>
|
||||
<reference id="VcsHistoryActionsGroup"/>
|
||||
</group>
|
||||
<group id="Vcs.FileHistory.PresentationSettings"
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.util.ShutDownTracker
|
||||
import com.intellij.openapi.util.registry.RegistryValue
|
||||
import com.intellij.openapi.util.registry.RegistryValueListener
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager
|
||||
import com.intellij.openapi.vcs.VcsKey
|
||||
import com.intellij.openapi.vcs.VcsMappingListener
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.platform.backend.observation.trackActivity
|
||||
@@ -322,6 +323,11 @@ class VcsProjectLog(private val project: Project, private val coroutineScope: Co
|
||||
return VcsLogManager.findLogProviders(ProjectLevelVcsManager.getInstance(project).allVcsRoots.toList(), project)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSupportedVcs(project: Project): Set<VcsKey> {
|
||||
return getLogProviders(project).values.mapTo(mutableSetOf()) { it.supportedVcs }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getInstance(project: Project): VcsProjectLog = project.service<VcsProjectLog>()
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.vcs.log.ui.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.PerformInBackgroundOption;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsActions;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.VcsDataKeys;
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsLogBundle;
|
||||
import com.intellij.vcs.log.impl.HashImpl;
|
||||
import com.intellij.vcs.log.impl.VcsLogContentUtil;
|
||||
import com.intellij.vcs.log.impl.VcsLogNavigationUtil;
|
||||
import com.intellij.vcs.log.impl.VcsProjectLog;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiEx;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class ShowCommitInLogAction extends DumbAwareAction {
|
||||
private static final Logger LOG = Logger.getInstance(ShowCommitInLogAction.class);
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent event) {
|
||||
Project project = event.getData(CommonDataKeys.PROJECT);
|
||||
if (project == null) return;
|
||||
VcsRevisionNumber revision = getRevisionNumber(event);
|
||||
if (revision == null) return;
|
||||
|
||||
jumpToRevision(project, HashImpl.build(revision.asString()));
|
||||
}
|
||||
|
||||
protected @Nullable VcsRevisionNumber getRevisionNumber(@NotNull AnActionEvent event) {
|
||||
VcsRevisionNumber revision = event.getData(VcsDataKeys.VCS_REVISION_NUMBER);
|
||||
if (revision == null) {
|
||||
VcsFileRevision fileRevision = event.getData(VcsDataKeys.VCS_FILE_REVISION);
|
||||
if (fileRevision != null) {
|
||||
revision = fileRevision.getRevisionNumber();
|
||||
}
|
||||
}
|
||||
return revision;
|
||||
}
|
||||
|
||||
protected @Nullable VcsKey getVcsKey(@NotNull AnActionEvent event) {
|
||||
return event.getData(VcsDataKeys.VCS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ActionUpdateThread getActionUpdateThread() {
|
||||
return ActionUpdateThread.BGT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
VcsKey vcsKey = getVcsKey(e);
|
||||
e.getPresentation().setEnabled(project != null && getRevisionNumber(e) != null && vcsKey != null
|
||||
&& VcsProjectLog.getSupportedVcs(project).contains(vcsKey));
|
||||
e.getPresentation().setText(getActionText(project, vcsKey));
|
||||
}
|
||||
|
||||
private static @NlsActions.ActionText @NotNull String getActionText(@Nullable Project project, @Nullable VcsKey vcsKey) {
|
||||
if (project != null && vcsKey != null) {
|
||||
AbstractVcs vcs = VcsUtil.findVcsByKey(project, vcsKey);
|
||||
if (vcs != null) return VcsLogBundle.message("action.Vcs.Log.SelectInLog.text.template", vcs.getDisplayName());
|
||||
}
|
||||
return VcsLogBundle.message("action.Vcs.Log.SelectInLog.text");
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void jumpToRevision(@NotNull Project project, @NotNull Hash hash) {
|
||||
VcsLogContentUtil.runInMainLog(project, logUi -> jumpToRevisionUnderProgress(project, logUi, hash));
|
||||
}
|
||||
|
||||
private static void jumpToRevisionUnderProgress(@NotNull Project project,
|
||||
@NotNull VcsLogUiEx logUi,
|
||||
@NotNull Hash hash) {
|
||||
Future<Boolean> future = VcsLogNavigationUtil.jumpToHash(logUi, hash.asString(), false, true);
|
||||
if (!future.isDone()) {
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project,
|
||||
VcsLogBundle.message("vcs.log.show.commit.in.log.process", hash.asString()),
|
||||
false/*can not cancel*/,
|
||||
PerformInBackgroundOption.ALWAYS_BACKGROUND) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
future.get();
|
||||
}
|
||||
catch (CancellationException | InterruptedException ignored) {
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,6 +337,10 @@ public final class VcsLogUtil {
|
||||
@NotNull Collection<? extends VcsLogProvider> logProviders) {
|
||||
Set<AbstractVcs> vcs = ContainerUtil.map2SetNotNull(logProviders,
|
||||
provider -> VcsUtil.findVcsByKey(project, provider.getSupportedVcs()));
|
||||
return getVcsDisplayName(vcs);
|
||||
}
|
||||
|
||||
public static @Nls @NotNull String getVcsDisplayName(@NotNull Set<AbstractVcs> vcs) {
|
||||
if (vcs.size() != 1) return VcsLogBundle.message("vcs");
|
||||
return Objects.requireNonNull(getFirstItem(vcs)).getDisplayName();
|
||||
}
|
||||
|
||||
@@ -38,9 +38,6 @@
|
||||
<add-to-group group-id="Vcs.Browse"/>
|
||||
</action>
|
||||
|
||||
<action class="git4idea.log.GitShowCommitInLogAction" id="Git.SelectInGitLog">
|
||||
<add-to-group group-id="VcsSelectionHistoryDialog.Popup" anchor="after" relative-to-action="Vcs.CopyRevisionNumberAction"/>
|
||||
</action>
|
||||
<action class="git4idea.log.GitBrowseRepoAtRevisionAction" id="Git.BrowseRepoAtRevision"/>
|
||||
|
||||
<group class="git4idea.actions.GitCheckoutActionGroup" id="Git.CheckoutGroup" searchable="false"/>
|
||||
@@ -289,8 +286,6 @@
|
||||
<group id="Git.LogContextMenu"/>
|
||||
|
||||
<group id="Git.FileHistory.ContextMenu">
|
||||
<reference id="Git.SelectInGitLog"/>
|
||||
<separator/>
|
||||
<reference id="Git.Revert.In.Log"/>
|
||||
<separator/>
|
||||
<reference id="Git.CreateNewTag"/>
|
||||
|
||||
@@ -542,6 +542,7 @@ git.unstash.clear.confirmation.message=Remove all stashes? This cannot be undone
|
||||
git.unstash.clear.confirmation.title=Remove All Stashes?
|
||||
git.unstash.drop.confirmation.message=<html>Do you want to remove {0}?<br/>"{1}"</html>
|
||||
git.unstash.drop.confirmation.title=Remove Stash {0}?
|
||||
# suppress inspection "UnusedProperty": used by 3-party plugins
|
||||
vcs.history.action.gitlog=Show in Git Log
|
||||
|
||||
exportable.Git.Application.Settings.presentable.name=Git
|
||||
@@ -1111,6 +1112,7 @@ git.history.diff.handler.choose.parent.popup=Choose Parent to Compare
|
||||
git.history.diff.handler.load.changes.process=Loading changes\u2026
|
||||
git.history.diff.handler.git.show.error=Error happened while executing git show {0}:{1}
|
||||
git.history.diff.handler.no.changes.in.file.info=There are no changes to file {0} in this merge commit
|
||||
# suppress inspection "UnusedProperty": used by 3-party plugins
|
||||
git.log.show.commit.in.log.process=Searching for Revision {0}
|
||||
git.compare.branches.empty.status={0} contains all commits from {1}
|
||||
git.compare.branches.explanation.message=Commits that exist in {0} but don''t exist in {1}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.util.text.HtmlChunk;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.impl.HashImpl;
|
||||
import com.intellij.vcs.log.ui.actions.ShowCommitInLogAction;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -27,7 +28,7 @@ public class GitCommitTooltipLinkHandler extends TooltipLinkHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
GitShowCommitInLogAction.jumpToRevision(project, hash);
|
||||
ShowCommitInLogAction.jumpToRevision(project, hash);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,103 +1,8 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package git4idea.log;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.PerformInBackgroundOption;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vcs.VcsDataKeys;
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.impl.HashImpl;
|
||||
import com.intellij.vcs.log.impl.VcsLogContentUtil;
|
||||
import com.intellij.vcs.log.impl.VcsLogNavigationUtil;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiEx;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.intellij.vcs.log.ui.actions.ShowCommitInLogAction;
|
||||
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class GitShowCommitInLogAction extends DumbAwareAction {
|
||||
private static final Logger LOG = Logger.getInstance(GitShowCommitInLogAction.class);
|
||||
|
||||
public GitShowCommitInLogAction() {
|
||||
super(GitBundle.messagePointer("vcs.history.action.gitlog"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent event) {
|
||||
Project project = event.getData(CommonDataKeys.PROJECT);
|
||||
if (project == null) return;
|
||||
VcsRevisionNumber revision = getRevisionNumber(event);
|
||||
if (revision == null) return;
|
||||
|
||||
jumpToRevision(project, HashImpl.build(revision.asString()));
|
||||
}
|
||||
|
||||
protected @Nullable VcsRevisionNumber getRevisionNumber(@NotNull AnActionEvent event) {
|
||||
VcsRevisionNumber revision = event.getData(VcsDataKeys.VCS_REVISION_NUMBER);
|
||||
if (revision == null) {
|
||||
VcsFileRevision fileRevision = event.getData(VcsDataKeys.VCS_FILE_REVISION);
|
||||
if (fileRevision != null) {
|
||||
revision = fileRevision.getRevisionNumber();
|
||||
}
|
||||
}
|
||||
return revision;
|
||||
}
|
||||
|
||||
protected @Nullable VcsKey getVcsKey(@NotNull AnActionEvent event) {
|
||||
return event.getData(VcsDataKeys.VCS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ActionUpdateThread getActionUpdateThread() {
|
||||
return ActionUpdateThread.BGT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
e.getPresentation().setEnabled(project != null && getRevisionNumber(e) != null && Comparing.equal(getVcsKey(e), GitVcs.getKey()));
|
||||
}
|
||||
|
||||
static void jumpToRevision(@NotNull Project project, @NotNull Hash hash) {
|
||||
VcsLogContentUtil.runInMainLog(project, logUi -> jumpToRevisionUnderProgress(project, logUi, hash));
|
||||
}
|
||||
|
||||
private static void jumpToRevisionUnderProgress(@NotNull Project project,
|
||||
@NotNull VcsLogUiEx logUi,
|
||||
@NotNull Hash hash) {
|
||||
Future<Boolean> future = VcsLogNavigationUtil.jumpToHash(logUi, hash.asString(), false, true);
|
||||
if (!future.isDone()) {
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project,
|
||||
GitBundle.message("git.log.show.commit.in.log.process", hash.asString()),
|
||||
false/*can not cancel*/,
|
||||
PerformInBackgroundOption.ALWAYS_BACKGROUND) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
future.get();
|
||||
}
|
||||
catch (CancellationException | InterruptedException ignored) {
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@Deprecated
|
||||
public class GitShowCommitInLogAction extends ShowCommitInLogAction {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user