Search in sources :

Example 11 with SVNURL

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

the class SvnVcs method filterUniqueRoots.

@Override
public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) {
    if (in.size() <= 1)
        return in;
    final List<MyPair<S>> infos = new ArrayList<>(in.size());
    final SvnFileUrlMappingImpl mapping = (SvnFileUrlMappingImpl) getSvnFileUrlMapping();
    final List<S> notMatched = new LinkedList<>();
    for (S s : in) {
        final VirtualFile vf = convertor.convert(s);
        if (vf == null)
            continue;
        final File ioFile = virtualToIoFile(vf);
        SVNURL url = mapping.getUrlForFile(ioFile);
        if (url == null) {
            url = SvnUtil.getUrl(this, ioFile);
            if (url == null) {
                notMatched.add(s);
                continue;
            }
        }
        infos.add(new MyPair<>(vf, url.toString(), s));
    }
    final List<MyPair<S>> filtered = new UniqueRootsFilter().filter(infos);
    final List<S> converted = ObjectsConvertor.convert(filtered, o -> o.getSrc());
    if (!notMatched.isEmpty()) {
        // potential bug is here: order is not kept. but seems it only occurs for cases where result is sorted after filtering so ok
        converted.addAll(notMatched);
    }
    return converted;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SVNURL(org.tmatesoft.svn.core.SVNURL) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 12 with SVNURL

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

the class SvnRootsDetector method registerRootUrlFromNestedPoint.

private void registerRootUrlFromNestedPoint(@NotNull NestedCopyInfo info, @NotNull List<RootUrlInfo> nestedRoots) {
    // TODO: Seems there could be issues if myTopRoots contains nested roots => RootUrlInfo.myRoot could be incorrect
    // TODO: (not nearest ancestor) for new RootUrlInfo
    RootUrlInfo topRoot = findAncestorTopRoot(info.getFile());
    if (topRoot != null) {
        SVNURL repoRoot = info.getRootURL();
        repoRoot = repoRoot == null ? myRepositoryRoots.ask(info.getUrl(), info.getFile()) : repoRoot;
        if (repoRoot != null) {
            Node node = new Node(info.getFile(), info.getUrl(), repoRoot);
            nestedRoots.add(new RootUrlInfo(node, info.getFormat(), topRoot.getRoot(), info.getType()));
        }
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL)

Example 13 with SVNURL

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

the class SvnUtil method appendMultiParts.

public static SVNURL appendMultiParts(@NotNull final SVNURL base, @NotNull final String subPath) throws SVNException {
    if (StringUtil.isEmpty(subPath))
        return base;
    final List<String> parts = StringUtil.split(subPath.replace('\\', '/'), "/", true);
    SVNURL result = base;
    for (String part : parts) {
        result = result.appendPath(part, false);
    }
    return result;
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL)

Example 14 with SVNURL

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

the class SvnTestInteractiveAuthentication method requestClientAuthentication.

@Override
public SVNAuthentication requestClientAuthentication(String kind, SVNURL url, String realm, SVNErrorMessage errorMessage, SVNAuthentication previousAuth, boolean authMayBeStored) {
    authMayBeStored = authMayBeStored && mySaveData;
    Convertor<SVNURL, SVNAuthentication> convertor = myData.get(kind);
    SVNAuthentication result = convertor == null ? null : convertor.convert(url);
    if (result == null) {
        if (ISVNAuthenticationManager.USERNAME.equals(kind)) {
            result = new SVNUserNameAuthentication("username", authMayBeStored);
        } else if (ISVNAuthenticationManager.PASSWORD.equals(kind)) {
            result = new SVNPasswordAuthentication("username", "abc", authMayBeStored, url, false);
        } else if (ISVNAuthenticationManager.SSH.equals(kind)) {
            result = new SVNSSHAuthentication("username", "abc", -1, authMayBeStored, url, false);
        } else if (ISVNAuthenticationManager.SSL.equals(kind)) {
            result = new SVNSSLAuthentication(new File("aaa"), "abc", authMayBeStored, url, false);
        }
    }
    if (!ISVNAuthenticationManager.USERNAME.equals(kind)) {
        myManager.requested(ProviderType.interactive, url, realm, kind, result == null);
    }
    return result;
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) File(java.io.File)

Example 15 with SVNURL

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

the class RepositoryBrowserDialog method doCheckout.

protected void doCheckout(@Nullable final CheckoutProvider.Listener listener, final RepositoryTreeNode selectedNode) {
    if (selectedNode == null) {
        return;
    }
    SVNURL url = selectedNode.getURL();
    String relativePath = "";
    final DirectoryEntry entry = selectedNode.getSVNDirEntry();
    if (entry != null) {
        if (entry.getRepositoryRoot() != null) {
            if (!entry.getRepositoryRoot().equals(url)) {
                relativePath = SVNPathUtil.getRelativePath(entry.getRepositoryRoot().toString(), url.toDecodedString());
            }
        } else {
            relativePath = entry.getRelativePath();
        }
    } else {
        relativePath = url.getPath();
    }
    File dir = selectFile(SvnBundle.message("svn.checkout.destination.directory.title"), SvnBundle.message("svn.checkout.destination.directory.description"));
    if (dir == null) {
        return;
    }
    Project p = myProject;
    CheckoutOptionsDialog dialog = new CheckoutOptionsDialog(p, url, dir, SvnUtil.getVirtualFile(dir.getAbsolutePath()), relativePath);
    dialog.show();
    dir = dialog.getTarget();
    if (dialog.isOK() && dir != null) {
        final SVNRevision revision;
        try {
            revision = dialog.getRevision();
        } catch (ConfigurationException e) {
            Messages.showErrorDialog(SvnBundle.message("message.text.cannot.checkout", e.getMessage()), SvnBundle.message("message.title.check.out"));
            return;
        }
        SvnCheckoutProvider.doCheckout(myProject, dir, url.toString(), revision, dialog.getDepth(), dialog.isIgnoreExternals(), listener);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) SVNURL(org.tmatesoft.svn.core.SVNURL) DirectoryEntry(org.jetbrains.idea.svn.browse.DirectoryEntry) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Aggregations

SVNURL (org.tmatesoft.svn.core.SVNURL)93 SVNException (org.tmatesoft.svn.core.SVNException)37 File (java.io.File)31 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)15 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)8 VcsException (com.intellij.openapi.vcs.VcsException)7 Nullable (org.jetbrains.annotations.Nullable)7 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)7 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)7 ArrayList (java.util.ArrayList)6 NotNull (org.jetbrains.annotations.NotNull)6 Info (org.jetbrains.idea.svn.info.Info)6 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)5 FilePath (com.intellij.openapi.vcs.FilePath)4 SvnVcs (org.jetbrains.idea.svn.SvnVcs)3 SvnAuthenticationManager (org.jetbrains.idea.svn.auth.SvnAuthenticationManager)3 SVNDirEntry (org.tmatesoft.svn.core.SVNDirEntry)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Project (com.intellij.openapi.project.Project)2