Search in sources :

Example 1 with Info

use of org.jetbrains.idea.svn.info.Info in project intellij-community by JetBrains.

the class CmdBrowseClient method list.

@Override
public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable Depth depth, @Nullable DirectoryEntryConsumer handler) throws VcsException {
    assertUrl(target);
    List<String> parameters = new ArrayList<>();
    CommandUtil.put(parameters, target);
    CommandUtil.put(parameters, revision);
    CommandUtil.put(parameters, depth);
    parameters.add("--xml");
    CommandExecutor command = execute(myVcs, target, SvnCommandName.list, parameters, null);
    Info info = myFactory.createInfoClient().doInfo(target, revision);
    try {
        parseOutput(target.getURL(), command, handler, info != null ? info.getRepositoryRootURL() : null);
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ArrayList(java.util.ArrayList) CommandExecutor(org.jetbrains.idea.svn.commandLine.CommandExecutor) SVNException(org.tmatesoft.svn.core.SVNException) Info(org.jetbrains.idea.svn.info.Info) CommitInfo(org.jetbrains.idea.svn.checkin.CommitInfo)

Example 2 with Info

use of org.jetbrains.idea.svn.info.Info 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 Info

use of org.jetbrains.idea.svn.info.Info in project intellij-community by JetBrains.

the class InfoCommandRepositoryProvider method get.

@Nullable
@Override
public Repository get() {
    Repository result;
    if (myTarget.isURL()) {
        // TODO: Also could still execute info when target is url - either to use info for authentication or to just get correct repository
        // TODO: url in case of "read" operations are allowed anonymously.
        result = new Repository(myTarget.getURL());
    } else {
        Info info = myVcs.getInfo(myTarget.getFile());
        result = info != null ? new Repository(info.getRepositoryRootURL()) : null;
    }
    return result;
}
Also used : Info(org.jetbrains.idea.svn.info.Info) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with Info

use of org.jetbrains.idea.svn.info.Info in project intellij-community by JetBrains.

the class SvnMergeProvider method loadRevisions.

@NotNull
public MergeData loadRevisions(@NotNull final VirtualFile file) throws VcsException {
    final MergeData data = new MergeData();
    VcsRunnable runnable = () -> {
        File oldFile = null;
        File newFile = null;
        File workingFile = null;
        boolean mergeCase = false;
        SvnVcs vcs = SvnVcs.getInstance(myProject);
        Info info = vcs.getInfo(file);
        if (info != null) {
            oldFile = info.getConflictOldFile();
            newFile = info.getConflictNewFile();
            workingFile = info.getConflictWrkFile();
            mergeCase = workingFile == null || workingFile.getName().contains("working");
            // for debug
            if (workingFile == null) {
                LOG.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
            }
            if (mergeCase) {
                // this is merge case
                oldFile = info.getConflictNewFile();
                newFile = info.getConflictOldFile();
                workingFile = info.getConflictWrkFile();
            }
            data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
        } else {
            throw new VcsException("Could not get info for " + file.getPath());
        }
        if (oldFile == null || newFile == null || workingFile == null) {
            ByteArrayOutputStream bos = getBaseRevisionContents(vcs, file);
            data.ORIGINAL = bos.toByteArray();
            data.LAST = bos.toByteArray();
            data.CURRENT = readFile(virtualToIoFile(file));
        } else {
            data.ORIGINAL = readFile(oldFile);
            data.LAST = readFile(newFile);
            data.CURRENT = readFile(workingFile);
        }
        if (mergeCase) {
            final ByteArrayOutputStream contents = getBaseRevisionContents(vcs, file);
            if (!Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
                // swap base and server: another order of merge arguments
                byte[] original = data.ORIGINAL;
                data.ORIGINAL = data.LAST;
                data.LAST = original;
            }
        }
    };
    VcsUtil.runVcsProcessWithProgress(runnable, VcsBundle.message("multiple.file.merge.loading.progress.title"), false, myProject);
    return data;
}
Also used : SvnRevisionNumber(org.jetbrains.idea.svn.SvnRevisionNumber) VcsRunnable(com.intellij.vcsUtil.VcsRunnable) MergeData(com.intellij.openapi.vcs.merge.MergeData) VcsException(com.intellij.openapi.vcs.VcsException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Info(org.jetbrains.idea.svn.info.Info) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) SvnVcs(org.jetbrains.idea.svn.SvnVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with Info

use of org.jetbrains.idea.svn.info.Info in project intellij-community by JetBrains.

the class CreateBranchOrTagDialog method init.

protected void init() {
    super.init();
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    String revStr = "";
    Info info = vcs.getInfo(mySrcFile);
    if (info != null) {
        mySrcURL = info.getURL() == null ? null : info.getURL().toString();
        revStr = String.valueOf(info.getRevision());
        myURL = mySrcURL;
    }
    if (myURL == null) {
        return;
    }
    myWorkingCopyField.setText(mySrcFile.toString());
    myRepositoryField.setText(mySrcURL);
    myToURLText.setText(myURL);
    myRevisionPanel.setRevisionText(revStr);
    updateControls();
    myWorkingCopyRadioButton.setSelected(true);
}
Also used : RootUrlInfo(org.jetbrains.idea.svn.RootUrlInfo) Info(org.jetbrains.idea.svn.info.Info) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Aggregations

Info (org.jetbrains.idea.svn.info.Info)32 File (java.io.File)18 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 VcsException (com.intellij.openapi.vcs.VcsException)6 NotNull (org.jetbrains.annotations.NotNull)6 SVNURL (org.tmatesoft.svn.core.SVNURL)6 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)6 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)5 RootUrlInfo (org.jetbrains.idea.svn.RootUrlInfo)5 IOException (java.io.IOException)3 Nullable (org.jetbrains.annotations.Nullable)3 Test (org.junit.Test)3 SVNException (org.tmatesoft.svn.core.SVNException)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 FilePath (com.intellij.openapi.vcs.FilePath)2 ArrayList (java.util.ArrayList)2 SvnVcs (org.jetbrains.idea.svn.SvnVcs)2 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)2 WCInfo (org.jetbrains.idea.svn.dialogs.WCInfo)2 SvnChangeList (org.jetbrains.idea.svn.history.SvnChangeList)2