diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/CommittedChangesProvider.java b/platform/vcs-api/src/com/intellij/openapi/vcs/CommittedChangesProvider.java index 4a035ad82c81..5a5d11d9d8fd 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/CommittedChangesProvider.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/CommittedChangesProvider.java @@ -64,4 +64,6 @@ public interface CommittedChangesProvider getOneList(final VirtualFile file, final VcsRevisionNumber number) throws VcsException; + + RepositoryLocation getForNonLocal(final VirtualFile file); } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java b/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java index f8ae000b3b93..804a5b1ce008 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java @@ -34,6 +34,8 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import java.util.List; + /** * @author irengrig * Date: 3/16/11 @@ -60,6 +62,7 @@ public class ShowAllAffectedGenericAction extends AnAction { public static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile, final VcsKey vcsKey) { final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName()); if (vcs == null) return; + if (! isInLocalFSHack(virtualFile) && ! canPresentNonLocal(project, vcsKey, virtualFile)) return; final String title = VcsBundle.message("paths.affected.in.revision", revision instanceof ShortVcsRevisionNumber @@ -71,9 +74,20 @@ public class ShowAllAffectedGenericAction extends AnAction { @Override public void run(@NotNull ProgressIndicator indicator) { try { - final Pair pair = vcs.getCommittedChangesProvider().getOneList(virtualFile, revision); - if (pair != null) { - list[0] = pair.getFirst(); + final CommittedChangesProvider provider = vcs.getCommittedChangesProvider(); + if (isInLocalFSHack(virtualFile)) { + final Pair pair = provider.getOneList(virtualFile, revision); + if (pair != null) { + list[0] = pair.getFirst(); + } + } else { + final RepositoryLocation local = provider.getForNonLocal(virtualFile); + if (local != null) { + final List changes = provider.getCommittedChanges(provider.createDefaultSettings(), local, 1); + if (changes != null && changes.size() == 1) { + list[0] = changes.get(0); + } + } } } catch (VcsException e) { @@ -95,6 +109,12 @@ public class ShowAllAffectedGenericAction extends AnAction { }); } + private static boolean isInLocalFSHack(final VirtualFile vf) { + if (vf.isInLocalFileSystem()) return true; + final String url = vf.getPresentableUrl(); + return ! url.contains("://") && ! url.contains(":\\\\"); + } + private static String failedText(VirtualFile virtualFile, VcsRevisionNumber revision) { return "Show all affected files for " + virtualFile.getPath() + " at " + revision.asString() + " failed"; } @@ -108,6 +128,16 @@ public class ShowAllAffectedGenericAction extends AnAction { return; } final VirtualFile revisionVirtualFile = e.getData(VcsDataKeys.VCS_VIRTUAL_FILE); - e.getPresentation().setEnabled((e.getData(VcsDataKeys.VCS_FILE_REVISION) != null) && (revisionVirtualFile != null)); + boolean enabled = (e.getData(VcsDataKeys.VCS_FILE_REVISION) != null) && (revisionVirtualFile != null); + enabled = enabled && (isInLocalFSHack(revisionVirtualFile) || canPresentNonLocal(project, vcsKey, revisionVirtualFile)); + e.getPresentation().setEnabled(enabled); + } + + private static boolean canPresentNonLocal(Project project, VcsKey key, final VirtualFile file) { + final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(key.getName()); + if (vcs == null) return false; + final CommittedChangesProvider provider = vcs.getCommittedChangesProvider(); + if (provider == null) return false; + return provider.getForNonLocal(file) != null; } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CompositeCommittedChangesProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CompositeCommittedChangesProvider.java index 7f7702a55834..b6a7370ff14f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CompositeCommittedChangesProvider.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CompositeCommittedChangesProvider.java @@ -161,6 +161,11 @@ public class CompositeCommittedChangesProvider implements CommittedChangesProvid throw new UnsupportedOperationException(); } + @Override + public RepositoryLocation getForNonLocal(VirtualFile file) { + throw new UnsupportedOperationException(); + } + public static class CompositeChangeBrowserSettings extends ChangeBrowserSettings { private final Map myMap; private final Set myEnabledVcs = new HashSet(); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java index 7a7904a04683..d5eaf4db6a21 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java @@ -207,6 +207,11 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi return new Pair(result.get(), filePath); } + @Override + public RepositoryLocation getForNonLocal(VirtualFile file) { + return null; + } + public List getCommittedChanges(ChangeBrowserSettings settings, RepositoryLocation location, final int maxCount) throws VcsException { final CvsRepositoryLocation cvsLocation = (CvsRepositoryLocation) location; diff --git a/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java b/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java index 439afdf1fa62..a6ce3954f6cb 100644 --- a/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java +++ b/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java @@ -266,6 +266,11 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider< return new Pair(commit, ((GitFileRevision) history.get(history.size() - 1)).getPath()); } + @Override + public RepositoryLocation getForNonLocal(VirtualFile file) { + return null; + } + public int getFormatVersion() { return 0; } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java index 2356f8afd93f..2a16ca883658 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java @@ -286,4 +286,9 @@ public class HgCachingCommitedChangesProvider } return null; } + + @Override + public RepositoryLocation getForNonLocal(VirtualFile file) { + return null; + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java index b69913b752db..f1165d66d5e2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java @@ -25,6 +25,7 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ContentRevision; @@ -33,6 +34,7 @@ import com.intellij.openapi.vcs.history.VcsRevisionNumber; 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.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.AsynchConsumer; import com.intellij.util.Consumer; @@ -563,6 +565,12 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi return new Pair(result[0], new FilePathImpl(file)); } + @Override + public RepositoryLocation getForNonLocal(VirtualFile file) { + final String url = file.getPresentableUrl(); + return new SvnRepositoryLocation(FileUtil.toSystemIndependentName(url)); + } + private static class RenameContext { @NotNull private String myCurrentPath; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java index 85e799818441..ae4d715969ea 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java @@ -619,10 +619,10 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto super(vcs, url, pegRevision, lastPath, result, repoRootURL, null); } - @Override + /*@Override protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath) { return new SvnFileRevision(myVcs, SVNRevision.UNDEFINED, logEntry, myUrl, copyPath, null); - } + }*/ } private class MergeSourceColumnInfo extends ColumnInfo {