Search in sources :

Example 1 with SVNStatusClient

use of org.tmatesoft.svn.core.wc.SVNStatusClient in project MassBank-web by MassBank.

the class SVNClientWrapper method getStatus.

/*
	 * Collects status information on a single Working Copy item.
	 */
public StatusHandler getStatus() throws SVNException {
    SVNStatusClient client = this.manager.getStatusClient();
    StatusHandler status = null;
    boolean reportAll = false;
    boolean checkouted = false;
    int cnt = 0;
    while (true) {
        try {
            StatusHandler sh = new StatusHandler(checkouted);
            long revision = client.doStatus(this.workCopy, true, true, reportAll, false, true, sh);
            return sh;
        } catch (SVNException e1) {
            SVNErrorCode errCode = e1.getErrorMessage().getErrorCode();
            // E155007
            if (errCode == SVNErrorCode.WC_NOT_DIRECTORY) {
                try {
                    checkout();
                    reportAll = checkouted = true;
                } catch (SVNException e2) {
                    throw e2;
                }
            } else {
                int ret = handleError("delete", e1, ++cnt);
                switch(ret) {
                    case ERROR_NEXT_THROW:
                        throw e1;
                    case ERROR_NEXT_BREAK:
                        return null;
                    case ERROR_NEXT_RETRY:
                        continue;
                }
            }
        }
    }
}
Also used : SVNErrorCode(org.tmatesoft.svn.core.SVNErrorCode) SVNStatusClient(org.tmatesoft.svn.core.wc.SVNStatusClient) SVNException(org.tmatesoft.svn.core.SVNException)

Example 2 with SVNStatusClient

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

the class SvnBlameCommandTest method blame_givenCredentialsSupplied_doNotlogWarning.

@Test
public void blame_givenCredentialsSupplied_doNotlogWarning() throws Exception {
    BlameOutput output = mock(BlameOutput.class);
    InputFile inputFile = mock(InputFile.class);
    SvnConfiguration properties = mock(SvnConfiguration.class);
    SvnBlameCommand svnBlameCommand = new SvnBlameCommand(properties);
    SVNClientManager clientManager = mock(SVNClientManager.class);
    SVNLogClient logClient = mock(SVNLogClient.class);
    SVNStatusClient statusClient = mock(SVNStatusClient.class);
    SVNStatus status = mock(SVNStatus.class);
    when(properties.isEmpty()).thenReturn(true);
    when(clientManager.getLogClient()).thenReturn(logClient);
    when(clientManager.getStatusClient()).thenReturn(statusClient);
    when(status.getContentsStatus()).thenReturn(SVNStatusType.STATUS_NORMAL);
    when(inputFile.file()).thenReturn(mock(File.class));
    when(statusClient.doStatus(any(File.class), anyBoolean())).thenReturn(status);
    doThrow(SVNAuthenticationException.class).when(logClient).doAnnotate(any(File.class), any(SVNRevision.class), any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class), eq(null));
    assertThrows(IllegalStateException.class, () -> {
        svnBlameCommand.blame(clientManager, inputFile, output);
        assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
    });
}
Also used : SVNStatus(org.tmatesoft.svn.core.wc.SVNStatus) SVNStatusClient(org.tmatesoft.svn.core.wc.SVNStatusClient) BlameOutput(org.sonar.api.batch.scm.BlameCommand.BlameOutput) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) 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) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Example 3 with SVNStatusClient

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

the class SvnBlameCommandTest method blame_givenNoCredentials_logWarning.

@Test
public void blame_givenNoCredentials_logWarning() throws Exception {
    BlameOutput output = mock(BlameOutput.class);
    InputFile inputFile = mock(InputFile.class);
    SvnBlameCommand svnBlameCommand = newSvnBlameCommand();
    SVNClientManager clientManager = mock(SVNClientManager.class);
    SVNLogClient logClient = mock(SVNLogClient.class);
    SVNStatusClient statusClient = mock(SVNStatusClient.class);
    SVNStatus status = mock(SVNStatus.class);
    when(clientManager.getLogClient()).thenReturn(logClient);
    when(clientManager.getStatusClient()).thenReturn(statusClient);
    when(status.getContentsStatus()).thenReturn(SVNStatusType.STATUS_NORMAL);
    when(inputFile.file()).thenReturn(mock(File.class));
    when(statusClient.doStatus(any(File.class), anyBoolean())).thenReturn(status);
    doThrow(SVNAuthenticationException.class).when(logClient).doAnnotate(any(File.class), any(SVNRevision.class), any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class), eq(null));
    assertThrows(IllegalStateException.class, () -> {
        svnBlameCommand.blame(clientManager, inputFile, output);
        assertThat(logTester.logs(LoggerLevel.WARN)).contains("Authentication to SVN server is required but no " + "authentication data was passed to the scanner");
    });
}
Also used : SVNStatus(org.tmatesoft.svn.core.wc.SVNStatus) SVNStatusClient(org.tmatesoft.svn.core.wc.SVNStatusClient) BlameOutput(org.sonar.api.batch.scm.BlameCommand.BlameOutput) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) 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) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Aggregations

SVNStatusClient (org.tmatesoft.svn.core.wc.SVNStatusClient)3 File (java.io.File)2 ZipFile (java.util.zip.ZipFile)2 Test (org.junit.Test)2 InputFile (org.sonar.api.batch.fs.InputFile)2 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)2 BlameOutput (org.sonar.api.batch.scm.BlameCommand.BlameOutput)2 SVNClientManager (org.tmatesoft.svn.core.wc.SVNClientManager)2 SVNLogClient (org.tmatesoft.svn.core.wc.SVNLogClient)2 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)2 SVNStatus (org.tmatesoft.svn.core.wc.SVNStatus)2 SVNErrorCode (org.tmatesoft.svn.core.SVNErrorCode)1 SVNException (org.tmatesoft.svn.core.SVNException)1