3

这是一个奇怪的。我希望你能帮忙。

我正在尝试使用 SVNKit 设置和调用 doLog() 。设置有点复杂,我不确定一些参数。错误是(我认为)一些“未知”字符被插入到 SVN URL 中,可能是因为设置不正确。这是经过稍微清理的代码:

    // 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();
    }

这是调试和堆栈跟踪信息:

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()

问题是svn: '/svn/Training/!svn/bc/0/PDX_Cycle_2_2011' path not found。我不知道为什么!svn/bc/0在路径名中。


编辑:

看来我需要在修订方面做得更好。我改变了这一行:

SVNRevision endRevision = SVNRevision.HEAD;

这有很大帮助。另外,我从 doLog() 参数中取出了路径:

String[] paths = { "" };

...并将它们放入 URL:

String path = "svn/Training/PDX_Cycle_2_2011";

修订似乎是最大的问题。感谢您的意见。

4

1 回答 1

2

总而言之,它知道这!svn/bc/0是一个合法的 URL,并且它指向修订版零。因此,将结束版本更改为 HEAD 而不是 -1 使其工作。

于 2012-08-27T22:41:04.460 回答