Search in sources :

Example 1 with ISVNOptions

use of org.tmatesoft.svn.core.wc.ISVNOptions in project sonarqube by SonarSource.

the class SvnScmSupport method newSvnClientManager.

static SVNClientManager newSvnClientManager(SvnConfiguration configuration) {
    ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
    final char[] passwordValue = getCharsOrNull(configuration.password());
    final char[] passPhraseValue = getCharsOrNull(configuration.passPhrase());
    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(null, configuration.username(), passwordValue, configuration.privateKey(), passPhraseValue, false);
    return SVNClientManager.newInstance(options, authManager);
}
Also used : ISVNOptions(org.tmatesoft.svn.core.wc.ISVNOptions) ISVNAuthenticationManager(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager)

Example 2 with ISVNOptions

use of org.tmatesoft.svn.core.wc.ISVNOptions in project sonarqube by SonarSource.

the class SvnBlameCommandTest method checkout.

private File checkout(String scmUrl) throws Exception {
    ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
    ISVNAuthenticationManager isvnAuthenticationManager = SVNWCUtil.createDefaultAuthenticationManager(null, null, (char[]) null, false);
    SVNClientManager svnClientManager = SVNClientManager.newInstance(options, isvnAuthenticationManager);
    File out = temp.newFolder();
    SVNUpdateClient updateClient = svnClientManager.getUpdateClient();
    SvnCheckout co = updateClient.getOperationsFactory().createCheckout();
    co.setUpdateLocksOnDemand(updateClient.isUpdateLocksOnDemand());
    co.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(scmUrl), SVNRevision.HEAD));
    co.setSingleTarget(SvnTarget.fromFile(out));
    co.setRevision(SVNRevision.HEAD);
    co.setDepth(SVNDepth.INFINITY);
    co.setAllowUnversionedObstructions(false);
    co.setIgnoreExternals(updateClient.isIgnoreExternals());
    co.setExternalsHandler(SvnCodec.externalsHandler(updateClient.getExternalsHandler()));
    co.setTargetWorkingCopyFormat(wcVersion);
    co.run();
    return out;
}
Also used : SVNUpdateClient(org.tmatesoft.svn.core.wc.SVNUpdateClient) ISVNOptions(org.tmatesoft.svn.core.wc.ISVNOptions) ISVNAuthenticationManager(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager) SvnCheckout(org.tmatesoft.svn.core.wc2.SvnCheckout) ZipFile(java.util.zip.ZipFile) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager)

Example 3 with ISVNOptions

use of org.tmatesoft.svn.core.wc.ISVNOptions in project omegat by omegat-org.

the class SVNRemoteRepository2 method isSVNRepository.

/**
 * Determines whether or not the supplied URL represents a valid Subversion repository.
 *
 * <p>
 * Does the equivalent of <code>svn info <i>url</i></code>.
 *
 * @param url
 *            URL of supposed remote repository
 * @return true if repository appears to be valid, false otherwise
 */
public static boolean isSVNRepository(String url) {
    // Heuristics to save some waiting time
    try {
        ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
        SVNClientManager ourClientManager = SVNClientManager.newInstance(options, (ISVNAuthenticationManager) null);
        ourClientManager.getWCClient().doInfo(SVNURL.parseURIEncoded(SVNEncodingUtil.autoURIEncode(url)), SVNRevision.HEAD, SVNRevision.HEAD);
    } catch (SVNAuthenticationException ex) {
        // https://twitter.com/amadlonkay/status/699716236372889600
        return true;
    } catch (SVNException ex) {
        return false;
    }
    return true;
}
Also used : ISVNOptions(org.tmatesoft.svn.core.wc.ISVNOptions) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager)

Example 4 with ISVNOptions

use of org.tmatesoft.svn.core.wc.ISVNOptions in project omegat by omegat-org.

the class SVNRemoteRepository2 method init.

@Override
public void init(RepositoryDefinition repo, File dir, ProjectTeamSettings teamSettings) throws Exception {
    config = repo;
    baseDirectory = dir;
    projectTeamSettings = teamSettings;
    String predefinedUser = repo.getOtherAttributes().get(new QName("svnUsername"));
    String predefinedPass = repo.getOtherAttributes().get(new QName("svnPassword"));
    if (predefinedUser == null) {
        predefinedUser = SVNURL.parseURIEncoded(repo.getUrl()).getUserInfo();
    }
    ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
    ISVNAuthenticationManager authManager = new SVNAuthenticationManager(repo.getUrl(), predefinedUser, predefinedPass, teamSettings);
    ourClientManager = SVNClientManager.newInstance(options, authManager);
    if (baseDirectory.exists()) {
        ourClientManager.getWCClient().doCleanup(baseDirectory);
        ourClientManager.getWCClient().doRevert(new File[] { baseDirectory }, SVNDepth.fromRecurse(true), null);
    }
}
Also used : ISVNOptions(org.tmatesoft.svn.core.wc.ISVNOptions) ISVNAuthenticationManager(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager) QName(javax.xml.namespace.QName) ISVNAuthenticationManager(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager)

Aggregations

ISVNOptions (org.tmatesoft.svn.core.wc.ISVNOptions)4 ISVNAuthenticationManager (org.tmatesoft.svn.core.auth.ISVNAuthenticationManager)3 SVNClientManager (org.tmatesoft.svn.core.wc.SVNClientManager)2 File (java.io.File)1 ZipFile (java.util.zip.ZipFile)1 QName (javax.xml.namespace.QName)1 InputFile (org.sonar.api.batch.fs.InputFile)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 SVNUpdateClient (org.tmatesoft.svn.core.wc.SVNUpdateClient)1 SvnCheckout (org.tmatesoft.svn.core.wc2.SvnCheckout)1