3

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://ksnortum@svn.hostname.com:8443
org.tmatesoft.svn.core.SVNException: svn: '/svn/Training/!svn/bc/0/PDX_Cycle_2_2011' path not found: 404 Not Found (https://ksnortum@svn.hostname.com: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.

ksnortum
  • 2,809
  • 4
  • 27
  • 36
  • I could imagine that the "@" sign in the password is causing the problem in this cause? Can you change to use the AuthenticationManager in SVNKit instead where username and password are given differently and not via the URI (http://en.wikipedia.org/wiki/URI_scheme)? – khmarbaise Feb 15 '12 at 17:47
  • The !svn/bc/OK is OK for DAV-repositories. However, the "0" means revision 0: the problem is that you are using peg-revision 0, i.e. you want to access "url" at revision 0. Unless "url" is the repository root, that will fail. – mstrap Feb 15 '12 at 19:25

1 Answers1

2

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.

ksnortum
  • 2,809
  • 4
  • 27
  • 36