Search in sources :

Example 1 with SvnOperationFactory

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

the class SvnKitManager method createOperationFactory.

@NotNull
public SvnOperationFactory createOperationFactory() {
    SvnOperationFactory result = new OperationFactory();
    result.setOptions(getSvnOptions());
    result.setRepositoryPool(getPool());
    result.setAuthenticationManager(getAuthenticationManager());
    return result;
}
Also used : SvnOperationFactory(org.tmatesoft.svn.core.wc2.SvnOperationFactory) SvnOperationFactory(org.tmatesoft.svn.core.wc2.SvnOperationFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with SvnOperationFactory

use of org.tmatesoft.svn.core.wc2.SvnOperationFactory in project spring-cloud-config by spring-cloud.

the class SVNKitEnvironmentRepositoryIntegrationTests method updateRepoForUpdate.

private void updateRepoForUpdate(String uri) throws SVNException, FileNotFoundException, IOException {
    SvnOperationFactory svnFactory = new SvnOperationFactory();
    final SvnCheckout checkout = svnFactory.createCheckout();
    checkout.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(uri)));
    checkout.setSingleTarget(SvnTarget.fromFile(this.workingDir));
    checkout.run();
    // update bar.properties
    File barProps = new File(this.workingDir, "trunk/bar.properties");
    StreamUtils.copy("foo: foo", Charset.defaultCharset(), new FileOutputStream(barProps));
    // commit to repo
    SvnCommit svnCommit = svnFactory.createCommit();
    svnCommit.setCommitMessage("update bar.properties");
    svnCommit.setSingleTarget(SvnTarget.fromFile(barProps));
    svnCommit.run();
}
Also used : FileOutputStream(java.io.FileOutputStream) SvnOperationFactory(org.tmatesoft.svn.core.wc2.SvnOperationFactory) SvnCheckout(org.tmatesoft.svn.core.wc2.SvnCheckout) File(java.io.File) SvnCommit(org.tmatesoft.svn.core.wc2.SvnCommit)

Example 3 with SvnOperationFactory

use of org.tmatesoft.svn.core.wc2.SvnOperationFactory in project spring-cloud-config by spring-cloud.

the class SvnKitEnvironmentRepository method update.

private String update(SvnOperationFactory svnOperationFactory, String label) throws SVNException {
    logger.debug("Repo already checked out - updating instead.");
    try {
        final SvnUpdate update = svnOperationFactory.createUpdate();
        update.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory()));
        long[] ids = update.run();
        StringBuilder version = new StringBuilder();
        for (long id : ids) {
            if (version.length() > 0) {
                version.append(",");
            }
            version.append(id);
        }
        return version.toString();
    } catch (Exception e) {
        String message = "Could not update remote for " + label + " (current local=" + getWorkingDirectory().getPath() + "), remote: " + this.getUri() + ")";
        if (logger.isDebugEnabled()) {
            logger.debug(message, e);
        } else if (logger.isWarnEnabled()) {
            logger.warn(message);
        }
    }
    final SVNStatus status = SVNClientManager.newInstance().getStatusClient().doStatus(getWorkingDirectory(), false);
    return status != null ? status.getRevision().toString() : null;
}
Also used : SVNStatus(org.tmatesoft.svn.core.wc.SVNStatus) SvnUpdate(org.tmatesoft.svn.core.wc2.SvnUpdate) SVNException(org.tmatesoft.svn.core.SVNException)

Example 4 with SvnOperationFactory

use of org.tmatesoft.svn.core.wc2.SvnOperationFactory in project spring-cloud-config by spring-cloud.

the class SvnKitEnvironmentRepository method checkout.

private String checkout(SvnOperationFactory svnOperationFactory) throws SVNException {
    logger.debug("Checking out " + getUri() + " to: " + getWorkingDirectory().getAbsolutePath());
    final SvnCheckout checkout = svnOperationFactory.createCheckout();
    checkout.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(getUri())));
    checkout.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory()));
    Long id = checkout.run();
    if (id == null) {
        return null;
    }
    return id.toString();
}
Also used : SvnCheckout(org.tmatesoft.svn.core.wc2.SvnCheckout)

Example 5 with SvnOperationFactory

use of org.tmatesoft.svn.core.wc2.SvnOperationFactory in project omegat by omegat-org.

the class ConvertProject26to37team method getSVNTmxVersion.

/**
 * Get version of "omegat/project_save.tmx" in SVN.
 */
private static String getSVNTmxVersion(File wc) throws Exception {
    final SvnOperationFactory of = new SvnOperationFactory();
    final SvnGetInfo infoOp = of.createGetInfo();
    infoOp.setSingleTarget(SvnTarget.fromFile(new File(wc, "omegat/project_save.tmx")));
    infoOp.setDepth(SVNDepth.EMPTY);
    SvnInfo info = infoOp.run();
    long r = info.getRevision();
    return Long.toString(r);
}
Also used : SvnOperationFactory(org.tmatesoft.svn.core.wc2.SvnOperationFactory) SvnInfo(org.tmatesoft.svn.core.wc2.SvnInfo) SvnGetInfo(org.tmatesoft.svn.core.wc2.SvnGetInfo) File(java.io.File)

Aggregations

SvnOperationFactory (org.tmatesoft.svn.core.wc2.SvnOperationFactory)6 File (java.io.File)3 SvnCheckout (org.tmatesoft.svn.core.wc2.SvnCheckout)2 SvnGetInfo (org.tmatesoft.svn.core.wc2.SvnGetInfo)2 SvnInfo (org.tmatesoft.svn.core.wc2.SvnInfo)2 FileOutputStream (java.io.FileOutputStream)1 NotNull (org.jetbrains.annotations.NotNull)1 SVNException (org.tmatesoft.svn.core.SVNException)1 SVNURL (org.tmatesoft.svn.core.SVNURL)1 ISVNAuthenticationManager (org.tmatesoft.svn.core.auth.ISVNAuthenticationManager)1 SVNStatus (org.tmatesoft.svn.core.wc.SVNStatus)1 SvnCommit (org.tmatesoft.svn.core.wc2.SvnCommit)1 SvnExport (org.tmatesoft.svn.core.wc2.SvnExport)1 SvnUpdate (org.tmatesoft.svn.core.wc2.SvnUpdate)1