Search in sources :

Example 1 with SvnGetInfo

use of org.tmatesoft.svn.core.wc2.SvnGetInfo in project GMM by Katharsas.

the class SVNTest method latestRevision.

/**
 * Find out at which revision number the repo is at.
 * Can also be used on single files to find out in which revision the last changed occured to them.
 */
public void latestRevision() throws SVNException {
    final SvnGetInfo operation = svnOperationFactory.createGetInfo();
    operation.setSingleTarget(workingCopy);
    final SvnInfo info = operation.run();
    final long revision = info.getRevision();
}
Also used : SvnInfo(org.tmatesoft.svn.core.wc2.SvnInfo) SvnGetInfo(org.tmatesoft.svn.core.wc2.SvnGetInfo)

Example 2 with SvnGetInfo

use of org.tmatesoft.svn.core.wc2.SvnGetInfo in project GMM by Katharsas.

the class SvnPlugin method checkRepoAvailable.

/**
 * @return Root URL of the SVN repo as opposed to the checked out URL.
 */
private SVNURL checkRepoAvailable() {
    final SvnGetInfo operation = svnOperationFactory.createGetInfo();
    operation.setSingleTarget(repository);
    try {
        final SvnInfo info = operation.run();
        logger.info("Successfully reached SVN repository at uri '" + repository.getPathOrUrlDecodedString() + "'.");
        return info.getRepositoryRootUrl();
    } catch (final SVNException e) {
        logger.error("Could not reach SVN repository at uri '" + repository.getPathOrUrlDecodedString() + "'!", e);
        throw new UncheckedSVNExeption(e);
    }
}
Also used : SvnInfo(org.tmatesoft.svn.core.wc2.SvnInfo) SVNException(org.tmatesoft.svn.core.SVNException) SvnGetInfo(org.tmatesoft.svn.core.wc2.SvnGetInfo)

Example 3 with SvnGetInfo

use of org.tmatesoft.svn.core.wc2.SvnGetInfo 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)

Example 4 with SvnGetInfo

use of org.tmatesoft.svn.core.wc2.SvnGetInfo in project GMM by Katharsas.

the class SvnPlugin method initializeWorkingCopy.

/**
 * @return Current revision of local working copy.
 */
private void initializeWorkingCopy(File workingCopyFile) {
    final String workingCopyString = workingCopyFile.toString();
    if (workingCopyFile.exists()) {
        if (workingCopyFile.isDirectory()) {
            final SvnGetInfo operation = svnOperationFactory.createGetInfo();
            operation.setSingleTarget(workingCopy);
            SvnInfo info = null;
            try {
                info = operation.run();
            } catch (final SVNException e) {
            }
            if (info != null) {
                logger.info("Located existing working copy at path '" + workingCopyString + "'.");
                verifyExistingWorkingCopy();
            } else {
                logger.warn("Could not locate working copy at path '" + workingCopyString + "'! Creating new one.");
                if (workingCopyFile.list().length > 0) {
                    throw new ConfigurationException("Cannot create new working copy because directory is not empty! Path: '" + workingCopyString + "'");
                }
                createNewWorkingCopy();
            }
        } else {
            throw new ConfigurationException("Path to working copy is not a directory! Path:'" + workingCopyString + "'");
        }
    } else {
        logger.warn("Could not locate SVN working copy at path '" + workingCopyString + "'! Creating new one.");
        fileService.createDirectory(workingCopyFile.toPath());
        createNewWorkingCopy();
    }
}
Also used : ConfigurationException(gmm.ConfigurationException) SvnInfo(org.tmatesoft.svn.core.wc2.SvnInfo) SVNException(org.tmatesoft.svn.core.SVNException) SvnGetInfo(org.tmatesoft.svn.core.wc2.SvnGetInfo)

Example 5 with SvnGetInfo

use of org.tmatesoft.svn.core.wc2.SvnGetInfo in project GMM by Katharsas.

the class SvnPlugin method retrieveRevision.

/**
 * @return Current revision of remote repository or working copy.
 */
private long retrieveRevision(SvnTarget target) {
    final SvnGetInfo operation = svnOperationFactory.createGetInfo();
    operation.setSingleTarget(target);
    final SvnInfo info = tryRun(operation);
    return info.getRevision();
}
Also used : SvnInfo(org.tmatesoft.svn.core.wc2.SvnInfo) SvnGetInfo(org.tmatesoft.svn.core.wc2.SvnGetInfo)

Aggregations

SvnGetInfo (org.tmatesoft.svn.core.wc2.SvnGetInfo)6 SvnInfo (org.tmatesoft.svn.core.wc2.SvnInfo)6 SVNException (org.tmatesoft.svn.core.SVNException)2 SvnOperationFactory (org.tmatesoft.svn.core.wc2.SvnOperationFactory)2 ConfigurationException (gmm.ConfigurationException)1 File (java.io.File)1 SVNURL (org.tmatesoft.svn.core.SVNURL)1