Search in sources :

Example 1 with DefaultSVNOptions

use of org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions in project intellij-community by JetBrains.

the class SvnBusyOnAddTest method getStatus.

@Nullable
private String getStatus(final File ioFile) throws SVNException {
    try {
        SVNStatusClient readClient = new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
        final SVNStatus status = readClient.doStatus(ioFile, false);
        return status == null ? null : status.getNodeStatus().toString();
    } catch (SVNException e) {
        if (SVNErrorCode.WC_NOT_WORKING_COPY.equals(e.getErrorMessage().getErrorCode())) {
            return null;
        }
        throw e;
    }
}
Also used : DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) SVNException(org.tmatesoft.svn.core.SVNException) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with DefaultSVNOptions

use of org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions in project intellij-community by JetBrains.

the class SvnBusyOnAddTest method testStatusDoesNotLockForWrite.

public void testStatusDoesNotLockForWrite() throws Exception {
    final File ioFile = new File(myWorkingCopyRoot, filename);
    ioFile.getParentFile().mkdirs();
    /*SVNWCClient client11 = new SVNWCClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
    client11.doAdd(ioFile.getParentFile(), true, false, true, true);*/
    ioFile.createNewFile();
    try {
        final SVNStatusClient readClient = new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
        final Semaphore semaphore = new Semaphore();
        final Semaphore semaphoreMain = new Semaphore();
        final Semaphore semaphoreWokeUp = new Semaphore();
        final AtomicReference<Boolean> wasUp = new AtomicReference<>(false);
        final ISVNStatusHandler handler = status -> {
            semaphore.waitFor();
            wasUp.set(true);
        };
        semaphore.down();
        semaphoreMain.down();
        semaphoreWokeUp.down();
        final SVNException[] exception = new SVNException[1];
        Thread thread = new Thread(() -> {
            try {
                semaphoreMain.up();
                readClient.doStatus(myWorkingCopyRoot, true, false, true, false, handler);
                semaphoreWokeUp.up();
            } catch (SVNException e) {
                exception[0] = e;
            }
        }, "svn test");
        thread.start();
        semaphoreMain.waitFor();
        TimeoutUtil.sleep(5);
        SVNWCClient client = new SVNWCClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
        client.doAdd(ioFile.getParentFile(), true, false, true, true);
        semaphore.up();
        semaphoreWokeUp.waitFor();
        Assert.assertEquals(true, wasUp.get().booleanValue());
        if (exception[0] != null) {
            throw exception[0];
        }
        thread.join();
    } finally {
        ioFile.delete();
    }
}
Also used : SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) PluginPathManager(com.intellij.openapi.application.PluginPathManager) SVNException(org.tmatesoft.svn.core.SVNException) PathManager(com.intellij.openapi.application.PathManager) Test(org.junit.Test) SVNErrorCode(org.tmatesoft.svn.core.SVNErrorCode) ISVNWCDb(org.tmatesoft.svn.core.internal.wc17.db.ISVNWCDb) AtomicReference(java.util.concurrent.atomic.AtomicReference) File(java.io.File) SVNWCContext(org.tmatesoft.svn.core.internal.wc17.SVNWCContext) org.tmatesoft.svn.core.wc(org.tmatesoft.svn.core.wc) Nullable(org.jetbrains.annotations.Nullable) Assert(junit.framework.Assert) TimeoutUtil(com.intellij.util.TimeoutUtil) Semaphore(com.intellij.util.concurrency.Semaphore) TestCase(junit.framework.TestCase) DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) SVNWCDb(org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb) Before(org.junit.Before) DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) AtomicReference(java.util.concurrent.atomic.AtomicReference) Semaphore(com.intellij.util.concurrency.Semaphore) SVNException(org.tmatesoft.svn.core.SVNException) File(java.io.File)

Example 3 with DefaultSVNOptions

use of org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions in project Gargoyle by callakrsos.

the class AbstractSVN method init.

/**
	 * 접속정보 초기화
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 5. 2.
	 * @param properties
	 */
public void init(Properties properties) {
    validate();
    try {
        svnURL = SVNURL.parseURIEncoded(getUrl());
        repository = SVNRepositoryFactory.create(svnURL);
        if ((getUserId() == null && getUserPassword() == null) || (getUserId().isEmpty() && getUserPassword().isEmpty())) {
            authManager = SVNWCUtil.createDefaultAuthenticationManager(SVNWCUtil.getDefaultConfigurationDirectory());
        } else {
            authManager = SVNWCUtil.createDefaultAuthenticationManager(getUserId(), getUserPassword().toCharArray());
        }
        repository.setAuthenticationManager(authManager);
        DefaultSVNOptions options = new DefaultSVNOptions();
        svnManager = SVNClientManager.newInstance(options, authManager);
    //			svnManager.dispose();
    //			repository.closeSession();
    } catch (SVNException e) {
        LOGGER.error(ValueUtil.toString(e));
    //			throw new RuntimeException(e);
    }
}
Also used : DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) SVNException(org.tmatesoft.svn.core.SVNException)

Example 4 with DefaultSVNOptions

use of org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions in project Corgi by kevinYin.

the class CreateDeploymentController method ensureSvnRevision.

private void ensureSvnRevision(DeploymentOrder order, ProjectModule module) {
    String tagName = order.getTagName().trim();
    String svnAddr = module.getRepoUrl() + (tagName.startsWith("/") ? tagName : "/" + tagName);
    try {
        SVNURL url = SVNURL.parseURIEncoded(svnAddr);
        DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
        SVNClientManager clientManager = SVNClientManager.newInstance(options, module.getSvnAccount(), module.getSvnPassword());
        SVNWCClient svnwcClient = clientManager.getWCClient();
        SVNInfo info = svnwcClient.doInfo(url, null, null);
        order.setVersionNo(info.getCommittedRevision().getNumber() + "");
    } catch (Exception e) {
        logger.error("读取版本号出错", e);
    }
    if (StringUtils.isEmpty(order.getVersionNo())) {
        throw new IllegalArgumentException("读取SVN版本号出错: " + order.getTagName());
    }
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) SVNException(org.tmatesoft.svn.core.SVNException)

Example 5 with DefaultSVNOptions

use of org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions in project intellij-community by JetBrains.

the class Idea87218Test method main.

public static void main(String[] args) {
    try {
        SVNStatusClient client = new SVNStatusClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
        File src = new File(ourWcPath, "file1.txt");
        SVNStatus status = client.doStatus(src, false);
        assert status != null && SVNStatusType.STATUS_NORMAL.equals(status.getNodeStatus());
        File dir = new File(ourWcPath, "unversioned");
        SVNStatus dirStatus = client.doStatus(dir, false);
        assert dirStatus != null && SVNStatusType.STATUS_UNVERSIONED.equals(dirStatus.getNodeStatus());
        File dst = new File(dir, "file1.txt");
        /*
      final SVNCopyClient copyClient = new SVNCopyClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
      final SVNCopySource svnCopySource = new SVNCopySource(SVNRevision.UNDEFINED, SVNRevision.WORKING, src);
      copyClient.doCopy(new SVNCopySource[]{svnCopySource}, dst, true, false, true);
      */
        SVNMoveClient moveClient = new SVNMoveClient((ISVNRepositoryPool) null, new DefaultSVNOptions());
        moveClient.doMove(src, dst);
    } catch (SVNException e) {
        e.printStackTrace();
    }
}
Also used : DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) SVNException(org.tmatesoft.svn.core.SVNException) File(java.io.File)

Aggregations

DefaultSVNOptions (org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions)11 SVNException (org.tmatesoft.svn.core.SVNException)9 File (java.io.File)6 SVNURL (org.tmatesoft.svn.core.SVNURL)4 Test (org.junit.Test)3 SVNWCContext (org.tmatesoft.svn.core.internal.wc17.SVNWCContext)3 ISVNWCDb (org.tmatesoft.svn.core.internal.wc17.db.ISVNWCDb)3 SVNWCDb (org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb)3 Nullable (org.jetbrains.annotations.Nullable)2 SVNCancelException (org.tmatesoft.svn.core.SVNCancelException)2 PathManager (com.intellij.openapi.application.PathManager)1 PluginPathManager (com.intellij.openapi.application.PluginPathManager)1 TimeoutUtil (com.intellij.util.TimeoutUtil)1 Semaphore (com.intellij.util.concurrency.Semaphore)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Assert (junit.framework.Assert)1 TestCase (junit.framework.TestCase)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 Before (org.junit.Before)1 ISVNDirEntryHandler (org.tmatesoft.svn.core.ISVNDirEntryHandler)1