mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs] Move "Show Affected Revisions" implementation to vcs-impl & fix it from annotate in modal dialog
This commit is contained in:
committed by
Aleksey Pivovarov
parent
d28eab0d13
commit
8a4d82a74a
@@ -25,6 +25,7 @@ import com.intellij.openapi.vcs.changes.CommitResultHandler;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.merge.MergeDialogCustomizer;
|
||||
import com.intellij.openapi.vcs.merge.MergeProvider;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
@@ -201,4 +202,12 @@ public abstract class AbstractVcsHelper {
|
||||
*/
|
||||
public abstract boolean commitChanges(@NotNull Collection<Change> changes, @NotNull LocalChangeList initialChangeList,
|
||||
@NotNull String commitMessage, @Nullable CommitResultHandler customResultHandler);
|
||||
|
||||
public abstract void loadAndShowCommittedChangesDetails(@NotNull Project project,
|
||||
@NotNull VcsRevisionNumber revision,
|
||||
@NotNull VirtualFile file,
|
||||
@NotNull VcsKey key,
|
||||
@Nullable RepositoryLocation location,
|
||||
boolean local);
|
||||
|
||||
}
|
||||
|
||||
+12
-114
@@ -19,26 +19,14 @@ import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.BackgroundFromStartOption;
|
||||
import com.intellij.openapi.vcs.history.ShortVcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vcs.vfs.VcsFileSystem;
|
||||
import com.intellij.openapi.vcs.vfs.VcsVirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author irengrig
|
||||
@@ -72,110 +60,20 @@ public class ShowAllAffectedGenericAction extends AnAction implements DumbAware
|
||||
}
|
||||
}
|
||||
|
||||
public static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile, final VcsKey vcsKey) {
|
||||
public static void showSubmittedFiles(@NotNull Project project,
|
||||
@NotNull VcsRevisionNumber revision,
|
||||
@NotNull VirtualFile virtualFile,
|
||||
@NotNull VcsKey vcsKey) {
|
||||
showSubmittedFiles(project, revision, virtualFile, vcsKey, null, false);
|
||||
}
|
||||
|
||||
public static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile,
|
||||
final VcsKey vcsKey, final RepositoryLocation location, final boolean isNonLocal) {
|
||||
final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
|
||||
if (vcs == null) return;
|
||||
if (isNonLocal && ! canPresentNonLocal(project, vcsKey, virtualFile)) return;
|
||||
|
||||
final String title = VcsBundle.message("paths.affected.in.revision",
|
||||
revision instanceof ShortVcsRevisionNumber
|
||||
? ((ShortVcsRevisionNumber) revision).toShortString()
|
||||
: revision.asString());
|
||||
final CommittedChangeList[] list = new CommittedChangeList[1];
|
||||
final FilePath[] targetPath = new FilePath[1];
|
||||
final VcsException[] exc = new VcsException[1];
|
||||
Task.Backgroundable task = new Task.Backgroundable(project, title, true, BackgroundFromStartOption.getInstance()) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
|
||||
if (!isNonLocal) {
|
||||
final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
|
||||
if (pair != null) {
|
||||
list[0] = pair.getFirst();
|
||||
targetPath[0] = pair.getSecond();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (location != null) {
|
||||
final ChangeBrowserSettings settings = provider.createDefaultSettings();
|
||||
settings.USE_CHANGE_BEFORE_FILTER = true;
|
||||
settings.CHANGE_BEFORE = revision.asString();
|
||||
final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
|
||||
if (changes != null && changes.size() == 1) {
|
||||
list[0] = changes.get(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
list[0] = getRemoteList(vcs, revision, virtualFile);
|
||||
/*final RepositoryLocation local = provider.getForNonLocal(virtualFile);
|
||||
if (local != null) {
|
||||
final String number = revision.asString();
|
||||
final ChangeBrowserSettings settings = provider.createDefaultSettings();
|
||||
final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue());
|
||||
if (changes != null) {
|
||||
for (CommittedChangeList change : changes) {
|
||||
if (number.equals(String.valueOf(change.getNumber()))) {
|
||||
list[0] = change;
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
exc[0] = e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
final AbstractVcsHelper instance = AbstractVcsHelper.getInstance(project);
|
||||
if (exc[0] != null) {
|
||||
instance.showError(exc[0], failedText(virtualFile, revision));
|
||||
}
|
||||
else if (list[0] == null) {
|
||||
Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
|
||||
}
|
||||
else {
|
||||
VirtualFile navigateToFile = targetPath[0] != null ?
|
||||
new VcsVirtualFile(targetPath[0].getPath(), null, VcsFileSystem.getInstance()) :
|
||||
virtualFile;
|
||||
instance.showChangesListBrowser(list[0], navigateToFile, title);
|
||||
}
|
||||
}
|
||||
};
|
||||
ProgressManager.getInstance().run(task);
|
||||
}
|
||||
|
||||
public static CommittedChangeList getRemoteList(final AbstractVcs vcs, final VcsRevisionNumber revision, final VirtualFile nonLocal)
|
||||
throws VcsException {
|
||||
final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
|
||||
final RepositoryLocation local = provider.getForNonLocal(nonLocal);
|
||||
if (local != null) {
|
||||
final String number = revision.asString();
|
||||
final ChangeBrowserSettings settings = provider.createDefaultSettings();
|
||||
final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue());
|
||||
if (changes != null) {
|
||||
for (CommittedChangeList change : changes) {
|
||||
if (number.equals(String.valueOf(change.getNumber()))) {
|
||||
return change;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String failedText(VirtualFile virtualFile, VcsRevisionNumber revision) {
|
||||
return "Show all affected files for " + virtualFile.getPath() + " at " + revision.asString() + " failed";
|
||||
public static void showSubmittedFiles(@NotNull Project project,
|
||||
@NotNull VcsRevisionNumber revision,
|
||||
@NotNull VirtualFile virtualFile,
|
||||
@NotNull VcsKey vcsKey,
|
||||
@Nullable RepositoryLocation location,
|
||||
boolean isNonLocal) {
|
||||
AbstractVcsHelper.getInstance(project).loadAndShowCommittedChangesDetails(project, revision, virtualFile, vcsKey, location, isNonLocal);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,13 +47,13 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.actions.AnnotateRevisionActionBase;
|
||||
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
|
||||
import com.intellij.openapi.vcs.annotate.ShowAllAffectedGenericAction;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.actions.CreatePatchFromChangesAction;
|
||||
import com.intellij.openapi.vcs.changes.committed.AbstractCalledLater;
|
||||
import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkHtmlRenderer;
|
||||
import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkRenderer;
|
||||
import com.intellij.openapi.vcs.changes.issueLinks.TableLinkMouseListener;
|
||||
import com.intellij.openapi.vcs.impl.AbstractVcsHelperImpl;
|
||||
import com.intellij.openapi.vcs.ui.ReplaceFileConfirmationDialog;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vcs.vfs.VcsFileSystem;
|
||||
@@ -1685,7 +1685,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
final VcsVirtualFile vf =
|
||||
new VcsVirtualFile(changedRepositoryPath.toPresentableString(), myRevision.getRevision(), VcsFileSystem.getInstance());
|
||||
try {
|
||||
myList = ShowAllAffectedGenericAction.getRemoteList(myVcs, myRevision.getRevisionNumber(), vf);
|
||||
myList = AbstractVcsHelperImpl.getRemoteList(myVcs, myRevision.getRevisionNumber(), vf);
|
||||
//myList = provider.getOneList(vf, myRevision.getRevisionNumber());
|
||||
}
|
||||
catch (VcsException e1) {
|
||||
|
||||
@@ -33,15 +33,18 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.progress.impl.CoreProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.actions.AnnotateToggleAction;
|
||||
@@ -60,6 +63,8 @@ import com.intellij.openapi.vcs.merge.MultipleFileMergeDialog;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangesBrowserSettingsEditor;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vcs.vfs.VcsFileSystem;
|
||||
import com.intellij.openapi.vcs.vfs.VcsVirtualFile;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
@@ -640,6 +645,105 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAndShowCommittedChangesDetails(@NotNull final Project project,
|
||||
@NotNull final VcsRevisionNumber revision,
|
||||
@NotNull final VirtualFile virtualFile,
|
||||
@NotNull VcsKey vcsKey,
|
||||
@Nullable final RepositoryLocation location,
|
||||
final boolean isNonLocal) {
|
||||
final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
|
||||
if (vcs == null) return;
|
||||
final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
|
||||
if (provider == null) return;
|
||||
if (isNonLocal && provider.getForNonLocal(virtualFile) == null) return;
|
||||
|
||||
final String title = VcsBundle.message("paths.affected.in.revision",
|
||||
revision instanceof ShortVcsRevisionNumber
|
||||
? ((ShortVcsRevisionNumber)revision).toShortString()
|
||||
: revision.asString());
|
||||
final CommittedChangeList[] list = new CommittedChangeList[1];
|
||||
final FilePath[] targetPath = new FilePath[1];
|
||||
final VcsException[] exc = new VcsException[1];
|
||||
Task.Backgroundable task = new Task.Backgroundable(project, title, true, BackgroundFromStartOption.getInstance()) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
if (!isNonLocal) {
|
||||
final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
|
||||
if (pair != null) {
|
||||
list[0] = pair.getFirst();
|
||||
targetPath[0] = pair.getSecond();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (location != null) {
|
||||
final ChangeBrowserSettings settings = provider.createDefaultSettings();
|
||||
settings.USE_CHANGE_BEFORE_FILTER = true;
|
||||
settings.CHANGE_BEFORE = revision.asString();
|
||||
final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
|
||||
if (changes != null && changes.size() == 1) {
|
||||
list[0] = changes.get(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
list[0] = getRemoteList(vcs, revision, virtualFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
exc[0] = e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (exc[0] != null) {
|
||||
showError(exc[0], failedText(virtualFile, revision));
|
||||
}
|
||||
else if (list[0] == null) {
|
||||
Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
|
||||
}
|
||||
else {
|
||||
VirtualFile navigateToFile = targetPath[0] != null ?
|
||||
new VcsVirtualFile(targetPath[0].getPath(), null, VcsFileSystem.getInstance()) :
|
||||
virtualFile;
|
||||
showChangesListBrowser(list[0], navigateToFile, title);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CoreProgressManager progressManager = (CoreProgressManager)ProgressManager.getInstance();
|
||||
progressManager.runProcessWithProgressAsynchronously(task, new EmptyProgressIndicator(), null, ModalityState.current());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CommittedChangeList getRemoteList(@NotNull AbstractVcs vcs,
|
||||
@NotNull VcsRevisionNumber revision,
|
||||
@NotNull VirtualFile nonLocal)
|
||||
throws VcsException {
|
||||
final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
|
||||
final RepositoryLocation local = provider.getForNonLocal(nonLocal);
|
||||
if (local != null) {
|
||||
final String number = revision.asString();
|
||||
final ChangeBrowserSettings settings = provider.createDefaultSettings();
|
||||
final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue());
|
||||
if (changes != null) {
|
||||
for (CommittedChangeList change : changes) {
|
||||
if (number.equals(String.valueOf(change.getNumber()))) {
|
||||
return change;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String failedText(@NotNull VirtualFile virtualFile, @NotNull VcsRevisionNumber revision) {
|
||||
return "Show all affected files for " + virtualFile.getPath() + " at " + revision.asString() + " failed";
|
||||
}
|
||||
|
||||
private static class AsynchronousListsLoader extends Task.Backgroundable {
|
||||
private final CommittedChangesProvider myProvider;
|
||||
private final RepositoryLocation myLocation;
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.vcs.changes.CommitResultHandler;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.merge.MergeDialogCustomizer;
|
||||
import com.intellij.openapi.vcs.merge.MergeProvider;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
@@ -227,4 +228,12 @@ public class MockVcsHelper extends AbstractVcsHelper {
|
||||
void showMergeDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAndShowCommittedChangesDetails(@NotNull Project project,
|
||||
@NotNull VcsRevisionNumber revision,
|
||||
@NotNull VirtualFile file,
|
||||
@NotNull VcsKey key,
|
||||
@Nullable RepositoryLocation location,
|
||||
boolean local) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.vcs.changes.CommitResultHandler;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.merge.MergeDialogCustomizer;
|
||||
import com.intellij.openapi.vcs.merge.MergeProvider;
|
||||
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
|
||||
@@ -173,6 +174,16 @@ public class HgMockVcsHelper extends AbstractVcsHelper {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAndShowCommittedChangesDetails(@NotNull Project project,
|
||||
@NotNull VcsRevisionNumber revision,
|
||||
@NotNull VirtualFile file,
|
||||
@NotNull VcsKey key,
|
||||
@Nullable RepositoryLocation location,
|
||||
boolean local) {
|
||||
|
||||
}
|
||||
|
||||
public void addListener(VcsHelperListener listener) {
|
||||
myListeners.add(listener);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user