Search in sources :

Example 1 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class SvnAnnotationProvider method annotate.

public FileAnnotation annotate(final VirtualFile file) throws VcsException {
    final SvnDiffProvider provider = (SvnDiffProvider) myVcs.getDiffProvider();
    final SVNRevision currentRevision = ((SvnRevisionNumber) provider.getCurrentRevision(file)).getRevision();
    final VcsRevisionDescription lastChangedRevision = provider.getCurrentRevisionDescription(file);
    if (lastChangedRevision == null) {
        throw new VcsException("Can not get current revision for file " + file.getPath());
    }
    final SVNRevision svnRevision = ((SvnRevisionNumber) lastChangedRevision.getRevisionNumber()).getRevision();
    if (!svnRevision.isValid()) {
        throw new VcsException("Can not get last changed revision for file: " + file.getPath() + "\nPlease run svn info for this file and file an issue.");
    }
    return annotate(file, new SvnFileRevision(myVcs, currentRevision, currentRevision, null, null, null, null, null), lastChangedRevision.getRevisionNumber(), true);
}
Also used : SvnFileRevision(org.jetbrains.idea.svn.history.SvnFileRevision) VcsException(com.intellij.openapi.vcs.VcsException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision)

Example 2 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class SvnAnnotationProvider method annotateNonExisting.

private SvnRemoteFileAnnotation annotateNonExisting(Pair<SvnChangeList, FilePath> pair, VcsFileRevision revision, Info info, Charset charset, final VirtualFile current) throws VcsException, SVNException, IOException {
    final File wasFile = pair.getSecond().getIOFile();
    final File root = getCommonAncestor(wasFile, info.getFile());
    if (root == null) {
        throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
    }
    final String relativePath = FileUtil.getRelativePath(root.getPath(), wasFile.getPath(), File.separatorChar);
    if (relativePath == null) {
        throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
    }
    Info wcRootInfo = myVcs.getInfo(root);
    if (wcRootInfo == null || wcRootInfo.getURL() == null) {
        throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
    }
    SVNURL wasUrl = wcRootInfo.getURL();
    final String[] strings = relativePath.replace('\\', '/').split("/");
    for (String string : strings) {
        wasUrl = wasUrl.appendPath(string, true);
    }
    final SVNRevision svnRevision = ((SvnRevisionNumber) revision.getRevisionNumber()).getRevision();
    byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromURL(wasUrl), svnRevision, svnRevision);
    final String contents = LoadTextUtil.getTextByBinaryPresentation(data, charset == null ? CharsetToolkit.UTF8_CHARSET : charset).toString();
    final SvnRemoteFileAnnotation result = new SvnRemoteFileAnnotation(myVcs, contents, revision.getRevisionNumber(), current);
    final AnnotationConsumer annotateHandler = createAnnotationHandler(ProgressManager.getInstance().getProgressIndicator(), result);
    boolean calculateMergeinfo = myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, wasUrl.toString());
    AnnotateClient client = myVcs.getFactory().createAnnotateClient();
    client.annotate(SvnTarget.fromURL(wasUrl, svnRevision), SVNRevision.create(1), svnRevision, calculateMergeinfo, getLogClientOptions(myVcs), annotateHandler);
    return result;
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) Info(org.jetbrains.idea.svn.info.Info) VcsException(com.intellij.openapi.vcs.VcsException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 3 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class CreateBranchOrTagDialog method isOKActionEnabled.

public boolean isOKActionEnabled() {
    myErrorLabel.setText(" ");
    if (myURL == null) {
        return false;
    }
    if (myBranchOrTagRadioButton.isSelected() && myBranchTagBaseComboBox.getComboBox().getSelectedItem() == null) {
        myErrorLabel.setText(SvnBundle.message("create.branch.no.base.location.error"));
        return false;
    }
    String url = getToURL();
    if (url != null && url.trim().length() > 0) {
        if (myRepositoryRadioButton.isSelected()) {
            SVNRevision revision;
            try {
                revision = myRevisionPanel.getRevision();
            } catch (ConfigurationException e) {
                revision = SVNRevision.UNDEFINED;
            }
            if (!revision.isValid() || revision.isLocal()) {
                myErrorLabel.setText(SvnBundle.message("create.branch.invalid.revision.error", myRevisionPanel.getRevisionText()));
                return false;
            }
            return true;
        } else if (myWorkingCopyRadioButton.isSelected()) {
            Info info = SvnVcs.getInstance(myProject).getInfo(mySrcFile);
            String srcUrl = info != null && info.getURL() != null ? info.getURL().toString() : null;
            if (srcUrl == null) {
                myErrorLabel.setText(SvnBundle.message("create.branch.no.working.copy.error", myWorkingCopyField.getText()));
                return false;
            }
            return true;
        }
    }
    return false;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) RootUrlInfo(org.jetbrains.idea.svn.RootUrlInfo) Info(org.jetbrains.idea.svn.info.Info)

Example 4 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class SvnDiffProvider method createFileContent.

@NotNull
@Override
public ContentRevision createFileContent(@NotNull VcsRevisionNumber revisionNumber, @NotNull VirtualFile selectedFile) {
    FilePath filePath = VcsUtil.getFilePath(selectedFile);
    SVNRevision svnRevision = ((SvnRevisionNumber) revisionNumber).getRevision();
    if (!SVNRevision.HEAD.equals(svnRevision) && revisionNumber.equals(getCurrentRevision(selectedFile))) {
        return SvnContentRevision.createBaseRevision(myVcs, filePath, svnRevision);
    }
    // not clear why we need it, with remote check..
    Status svnStatus = getFileStatus(VfsUtilCore.virtualToIoFile(selectedFile), false);
    return svnStatus != null && svnRevision.equals(svnStatus.getRevision()) ? SvnContentRevision.createBaseRevision(myVcs, filePath, svnRevision) : SvnContentRevision.createRemote(myVcs, filePath, svnRevision);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Status(org.jetbrains.idea.svn.status.Status) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class SvnChangeProviderContext method createPropertyRevision.

@Nullable
private ContentRevision createPropertyRevision(@NotNull Change change, @NotNull File file, boolean isBeforeRevision) throws SVNException {
    FilePath path = ChangesUtil.getFilePath(change);
    ContentRevision contentRevision = isBeforeRevision ? change.getBeforeRevision() : change.getAfterRevision();
    SVNRevision revision = isBeforeRevision ? SVNRevision.BASE : SVNRevision.WORKING;
    return new SimplePropertyRevision(getPropertyList(myVcs, file, revision), path, getRevisionNumber(contentRevision));
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) SimplePropertyRevision(org.jetbrains.idea.svn.history.SimplePropertyRevision) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)19 VcsException (com.intellij.openapi.vcs.VcsException)7 Info (org.jetbrains.idea.svn.info.Info)7 SVNURL (org.tmatesoft.svn.core.SVNURL)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 Ref (com.intellij.openapi.util.Ref)4 File (java.io.File)4 NotNull (org.jetbrains.annotations.NotNull)4 Nullable (org.jetbrains.annotations.Nullable)4 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)4 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)4 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 FilePath (com.intellij.openapi.vcs.FilePath)3 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)3 List (java.util.List)2 SVNException (org.tmatesoft.svn.core.SVNException)2 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Application (com.intellij.openapi.application.Application)1