Search in sources :

Example 6 with SVNLogClient

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

the class SvnKitBrowseClient method list.

@Override
public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable Depth depth, @Nullable DirectoryEntryConsumer handler) throws VcsException {
    assertUrl(target);
    SVNLogClient client = getLogClient();
    ISVNDirEntryHandler wrappedHandler = wrapHandler(handler);
    client.setIgnoreExternals(true);
    try {
        if (target.isFile()) {
            client.doList(target.getFile(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler);
        } else {
            client.doList(target.getURL(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler);
        }
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient)

Example 7 with SVNLogClient

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

the class SvnKitAnnotateClient method annotate.

@Override
public void annotate(@NotNull SvnTarget target, @NotNull SVNRevision startRevision, @NotNull SVNRevision endRevision, boolean includeMergedRevisions, @Nullable DiffOptions diffOptions, @Nullable AnnotationConsumer handler) throws VcsException {
    try {
        SVNLogClient client = myVcs.getSvnKitManager().createLogClient();
        client.setDiffOptions(toDiffOptions(diffOptions));
        if (target.isFile()) {
            client.doAnnotate(target.getFile(), target.getPegRevision(), startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), null);
        } else {
            client.doAnnotate(target.getURL(), target.getPegRevision(), startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), null);
        }
    } catch (SVNException e) {
        throw new VcsException(e);
    }
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient)

Example 8 with SVNLogClient

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

the class SVNLog method log.

public List<SVNLogEntry> log(String path, long startRevision, Date endDate, Consumer<Exception> exceptionHandler) {
    SVNLogClient logClient = getSvnManager().getLogClient();
    List<SVNLogEntry> result = new ArrayList<>();
    try {
        ISVNLogEntryHandler handler = logEntry -> {
            LOGGER.debug("path :: {}  rivision :: {} date :: {} author :: {} message :: {} ", path, logEntry.getRevision(), logEntry.getDate(), logEntry.getAuthor(), logEntry.getMessage());
            result.add(logEntry);
        };
        logServer(path, startRevision, endDate, logClient, handler);
    } catch (SVNException e) {
        LOGGER.error(ValueUtil.toString(e));
        if (exceptionHandler != null)
            exceptionHandler.accept(e);
    }
    return result;
}
Also used : ILogCommand(com.kyj.scm.manager.core.commons.ILogCommand) Properties(java.util.Properties) Logger(org.slf4j.Logger) URLDecoder(java.net.URLDecoder) SVNException(org.tmatesoft.svn.core.SVNException) Date(java.util.Date) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) File(java.io.File) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) List(java.util.List) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) ISVNLogEntryHandler(org.tmatesoft.svn.core.ISVNLogEntryHandler) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ArrayList(java.util.ArrayList) ISVNLogEntryHandler(org.tmatesoft.svn.core.ISVNLogEntryHandler) SVNException(org.tmatesoft.svn.core.SVNException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient)

Example 9 with SVNLogClient

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

the class SvnScmProviderTest method computeChangedPaths_should_not_crash_when_getRepositoryRootURL_getPath_is_empty.

@Test
public void computeChangedPaths_should_not_crash_when_getRepositoryRootURL_getPath_is_empty() throws SVNException {
    // verify assumptions about what SVNKit returns as svn root path for urls like http://svnserver/
    assertThat(SVNURL.parseURIEncoded("http://svnserver/").getPath()).isEmpty();
    assertThat(SVNURL.parseURIEncoded("http://svnserver").getPath()).isEmpty();
    SVNClientManager svnClientManagerMock = mock(SVNClientManager.class);
    SVNWCClient svnwcClientMock = mock(SVNWCClient.class);
    when(svnClientManagerMock.getWCClient()).thenReturn(svnwcClientMock);
    SVNLogClient svnLogClient = mock(SVNLogClient.class);
    when(svnClientManagerMock.getLogClient()).thenReturn(svnLogClient);
    SVNInfo svnInfoMock = mock(SVNInfo.class);
    when(svnwcClientMock.doInfo(any(), any())).thenReturn(svnInfoMock);
    // Simulate repository root on /, SVNKIT then returns an repository root url WITHOUT / at the end.
    when(svnInfoMock.getRepositoryRootURL()).thenReturn(SVNURL.parseURIEncoded("http://svnserver"));
    when(svnInfoMock.getURL()).thenReturn(SVNURL.parseURIEncoded("http://svnserver/myproject/trunk/"));
    assertThat(SvnScmProvider.computeChangedPaths(Paths.get("/"), svnClientManagerMock)).isEmpty();
}
Also used : SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient) SVNInfo(org.tmatesoft.svn.core.wc.SVNInfo) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) Test(org.junit.Test)

Example 10 with SVNLogClient

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

the class SvnBlameCommand method blame.

@VisibleForTesting
void blame(SVNClientManager clientManager, InputFile inputFile, BlameOutput output) {
    String filename = inputFile.relativePath();
    LOG.debug("Process file {}", filename);
    AnnotationHandler handler = new AnnotationHandler();
    try {
        if (!checkStatus(clientManager, inputFile)) {
            return;
        }
        SVNLogClient logClient = clientManager.getLogClient();
        logClient.setDiffOptions(new SVNDiffOptions(true, true, true));
        logClient.doAnnotate(inputFile.file(), SVNRevision.UNDEFINED, SVNRevision.create(1), SVNRevision.BASE, true, true, handler, null);
    } catch (SVNAuthenticationException e) {
        if (configuration.isEmpty()) {
            LOG.warn("Authentication to SVN server is required but no authentication data was passed to the scanner");
        }
        throw new IllegalStateException("Authentication error when executing blame for file " + filename, e);
    } catch (SVNException e) {
        throw new IllegalStateException("Error when executing blame for file " + filename, e);
    }
    List<BlameLine> lines = handler.getLines();
    if (lines.size() == inputFile.lines() - 1) {
        // SONARPLUGINS-3097 SVN do not report blame on last empty line
        lines.add(lines.get(lines.size() - 1));
    }
    output.blameResult(inputFile, lines);
}
Also used : BlameLine(org.sonar.api.batch.scm.BlameLine) SVNAuthenticationException(org.tmatesoft.svn.core.SVNAuthenticationException) SVNDiffOptions(org.tmatesoft.svn.core.wc.SVNDiffOptions) SVNException(org.tmatesoft.svn.core.SVNException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

SVNLogClient (org.tmatesoft.svn.core.wc.SVNLogClient)11 File (java.io.File)7 SVNException (org.tmatesoft.svn.core.SVNException)7 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)6 SVNClientManager (org.tmatesoft.svn.core.wc.SVNClientManager)5 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)3 ILogCommand (com.kyj.scm.manager.core.commons.ILogCommand)3 URLDecoder (java.net.URLDecoder)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Date (java.util.Date)3 List (java.util.List)3 Properties (java.util.Properties)3 Consumer (java.util.function.Consumer)3 Test (org.junit.Test)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 ISVNLogEntryHandler (org.tmatesoft.svn.core.ISVNLogEntryHandler)3 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2