2012-02-15 88 views
3

這是一個奇怪的問題。我希望你能幫忙。用Java中的SVNKit調用doLog()時出現奇怪的URL

我想安裝並調用與SVNKit doLog()。該設置有點複雜,我不確定一些參數。錯誤是(我認爲)有些「未知」字符會插入到SVN URL中,可能是因爲設置不正確。這裏是稍微消毒代碼:

// Auth manager 
    String userName = "ksnortum"; 
    String password = "[email protected]"; 
    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://[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() 

問題是svn: '/svn/Training/!svn/bc/0/PDX_Cycle_2_2011' path not found。我不知道爲什麼!svn/bc/0在路徑名中。


編輯:

它看起來像我需要做的修改比較好。我改變了這一行:

SVNRevision endRevision = SVNRevision.HEAD; 

這幫了很大忙。另外,我把路徑出doLog()則params的:

String[] paths = { "" }; 

...並把它們放到網址:

String path = "svn/Training/PDX_Cycle_2_2011"; 

的修訂似乎一直是最大的問題。感謝您的意見。

+0

我可以想象,密碼中的「@」符號導致了這個原因中的問題?你可以改變在SVNKit中使用AuthenticationManager,而不是通過URI(http://en.wikipedia.org/wiki/URI_scheme)給出不同的用戶名和密碼嗎? – khmarbaise 2012-02-15 17:47:50

+0

DAV存儲庫的!svn/bc/OK可以。但是,「0」表示修訂版本0:問題在於您使用的是peg-revision 0,即您想要在修訂版本0中訪問「url」。除非「url」是存儲庫根目錄,否則將失敗。 – mstrap 2012-02-15 19:25:40

回答

2

長和短的是知道!svn/bc/0是一個合法的URL,它指向修訂零。因此,將結束脩訂版更改爲HEAD而不是-1使其起作用。

相關問題