Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange URL when calling doLog() with SVNKit in Java

Tags:

java

svn

svnkit

Here's a strange one. I hope you can help.

I'm trying to setup and call doLog() with SVNKit. The setup is a little complex and I'm not sure of some of the parameters. The error is (I think) that some "unknown" characters get inserted into the SVN URL, maybe because of incorrect setup. Here's the code slightly sanitized:

    // Auth manager
    String userName = "ksnortum";
    String password = "p@ssw0rd";
    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( userName, password );

    // Options
    boolean readonly = true;
    ISVNOptions options = SVNWCUtil.createDefaultOptions( readonly );

    // Get log client
    SVNLogClient logClient = new SVNLogClient( authManager, options );

    // SVN URL parameters
    String protocol = "https";
    String userInfo = userName;
    String host = "svn.hostname.com";
    int port = 8443;
    String path = "";
    boolean uriEncoded = true;
    SVNURL url = null;

    // Create URL
    try {
        url = SVNURL.create( protocol, userInfo, host, port, path, uriEncoded );
    }
    catch ( SVNException e ) {
        System.out.println( "Can't create URL: " + e.toString() );
    }

    System.out.println( "URL: " + url.toString() ); // debug

    // Parameters for doLog()
    String[] paths = { "svn/Training/PDX_Cycle_2_2011" };
    SVNRevision pegRevision = SVNRevision.create( 0l );
    SVNRevision startRevision = SVNRevision.create( 0l );
    SVNRevision endRevision = SVNRevision.create( -1l );
    boolean stopOnCopy = false;
    boolean discoverChangedPaths = true;
    long limit = 9999l;

    // Log event handler
    ISVNLogEntryHandler handler = new ISVNLogEntryHandler() {

        /**
         * This method will process when doLog() is done
         */
        @Override
        public void handleLogEntry( SVNLogEntry logEntry ) throws SVNException {
            System.out.println( "Author: " + logEntry.getAuthor() );
            System.out.println( "Date: " + logEntry.getDate() );
            System.out.println( "Message: " + logEntry.getMessage() );
            System.out.println( "Revision: " + logEntry.getRevision() );
        }
    };

    // Do log
    try {
        logClient.doLog( url, paths, pegRevision, startRevision, endRevision, stopOnCopy, discoverChangedPaths, limit, handler );
    }
    catch ( SVNException e ) {
        System.out.println( "Error in doLog() " );
        e.printStackTrace();
    }

Here is the debug and stacktrace info:

URL: https://[email protected]:8443
org.tmatesoft.svn.core.SVNException: svn: '/svn/Training/!svn/bc/0/PDX_Cycle_2_2011' path not found: 404 Not Found (https://[email protected]:8443)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.logImpl(DAVRepository.java:986)
at org.tmatesoft.svn.core.io.SVNRepository.log(SVNRepository.java:1034)
at org.tmatesoft.svn.core.wc.SVNLogClient.doLog(SVNLogClient.java:1028)
at org.tmatesoft.svn.core.wc.SVNLogClient.doLog(SVNLogClient.java:895)
at org.tmatesoft.svn.core.wc.SVNLogClient.doLog(SVNLogClient.java:827)
at org.tmatesoft.svn.examples.repository.LogEntry.start(LogEntry.java:93)
at org.tmatesoft.svn.examples.repository.LogEntry.main(LogEntry.java:27)
Error in doLog()

The problem is svn: '/svn/Training/!svn/bc/0/PDX_Cycle_2_2011' path not found. I don't know why !svn/bc/0 is in the path name.


Edit:

It looks like I needed to do better with the revisions. I changed this line:

SVNRevision endRevision = SVNRevision.HEAD;

That helped a lot. Also, I took the paths out of the doLog() params:

String[] paths = { "" };

...and put them into the URL:

String path = "svn/Training/PDX_Cycle_2_2011";

The revision seems to have been the biggest problem. Thanks for your comments.

like image 258
ksnortum Avatar asked Jan 01 '26 00:01

ksnortum


1 Answers

The long and the short of it is knowing the !svn/bc/0 is a legitimate URL and that it points to the revision zero. So changing the ending revision to HEAD instead of -1 made it work.

like image 130
ksnortum Avatar answered Jan 02 '26 12:01

ksnortum