mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: mark content revision to allow easy vcs discovery inside same vcs plugin;
do not show "Compare Subversion Properties" in git log; allow to compare properties when called from "Browse Subversion Repository"
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.vcs.changes;
|
||||
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: Irina.Chernushina
|
||||
* Date: 6/14/12
|
||||
* Time: 5:13 PM
|
||||
*/
|
||||
public interface MarkerVcsContentRevision {
|
||||
VcsKey getVcsKey();
|
||||
}
|
||||
@@ -20,7 +20,9 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Throwable2Computable;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.impl.ContentRevisionCache;
|
||||
import com.intellij.openapi.vcs.impl.CurrentRevisionProvider;
|
||||
@@ -39,7 +41,7 @@ import java.io.IOException;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class SvnContentRevision implements ContentRevision {
|
||||
public class SvnContentRevision implements ContentRevision, MarkerVcsContentRevision {
|
||||
private final SvnVcs myVcs;
|
||||
protected final FilePath myFile;
|
||||
private final SVNRevision myRevision;
|
||||
@@ -145,4 +147,9 @@ public class SvnContentRevision implements ContentRevision {
|
||||
public String toString() {
|
||||
return myFile.getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VcsKey getVcsKey() {
|
||||
return SvnVcs.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
+24
-4
@@ -31,6 +31,7 @@ import com.intellij.openapi.vcs.VcsDataKeys;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ChangesUtil;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -70,11 +71,30 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen
|
||||
public void update(final AnActionEvent e) {
|
||||
final DataContext dataContext = e.getDataContext();
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
final Change[] changes = e.getData(getChangesKey());
|
||||
|
||||
final Presentation presentation = e.getPresentation();
|
||||
presentation.setVisible(VcsDataKeys.CHANGES.getData(dataContext) != null);
|
||||
presentation.setEnabled(enabled(project, changes));
|
||||
final Change[] data = VcsDataKeys.CHANGES.getData(dataContext);
|
||||
boolean showAction = checkThatChangesAreUnderSvn(data);
|
||||
presentation.setVisible(data != null && showAction);
|
||||
presentation.setEnabled(showAction);
|
||||
}
|
||||
|
||||
private boolean checkThatChangesAreUnderSvn(Change[] data) {
|
||||
boolean showAction = false;
|
||||
if (data != null) {
|
||||
for (Change change : data) {
|
||||
final ContentRevision before = change.getBeforeRevision();
|
||||
if (before != null) {
|
||||
showAction = showAction || before instanceof MarkerVcsContentRevision && SvnVcs.getKey().equals(((MarkerVcsContentRevision)before).getVcsKey());
|
||||
}
|
||||
final ContentRevision after = change.getAfterRevision();
|
||||
if (after != null) {
|
||||
showAction = showAction || after instanceof MarkerVcsContentRevision && SvnVcs.getKey().equals(((MarkerVcsContentRevision)after).getVcsKey());
|
||||
}
|
||||
if (showAction) break;
|
||||
}
|
||||
}
|
||||
return showAction;
|
||||
}
|
||||
|
||||
private boolean enabled(final Project project, final Change[] changes) {
|
||||
@@ -107,7 +127,7 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
final Change[] changes = e.getData(getChangesKey());
|
||||
|
||||
if (! enabled(project, changes)) {
|
||||
if (! checkThatChangesAreUnderSvn(changes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -18,11 +18,12 @@ package org.jetbrains.idea.svn.history;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.svn.SvnBundle;
|
||||
@@ -39,7 +40,7 @@ import org.tmatesoft.svn.core.wc.SVNWCClient;
|
||||
* Date: 2/22/12
|
||||
* Time: 10:28 AM
|
||||
*/
|
||||
public class SvnLazyPropertyContentRevision implements ContentRevision {
|
||||
public class SvnLazyPropertyContentRevision implements ContentRevision, MarkerVcsContentRevision {
|
||||
private final FilePath myPath;
|
||||
private final VcsRevisionNumber myNumber;
|
||||
private final Project myProject;
|
||||
@@ -101,4 +102,9 @@ public class SvnLazyPropertyContentRevision implements ContentRevision {
|
||||
public VcsRevisionNumber getRevisionNumber() {
|
||||
return myNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VcsKey getVcsKey() {
|
||||
return SvnVcs.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -30,8 +30,10 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Throwable2Computable;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
import com.intellij.openapi.vcs.actions.VcsContextFactory;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.impl.ContentRevisionCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,7 +49,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class SvnRepositoryContentRevision implements ContentRevision {
|
||||
public class SvnRepositoryContentRevision implements ContentRevision, MarkerVcsContentRevision {
|
||||
private final String myRepositoryRoot;
|
||||
private final SvnVcs myVcs;
|
||||
private final String myPath;
|
||||
@@ -180,4 +182,9 @@ public class SvnRepositoryContentRevision implements ContentRevision {
|
||||
public String getPath() {
|
||||
return myPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VcsKey getVcsKey() {
|
||||
return SvnVcs.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user