簡體   English   中英

如何使用SVNKit向SVN添加/提交新文件

[英]How to add/commit a new file to SVN with SVNKit

無法將文件添加並提交到subversion存儲庫。 使用以下代碼段:

SVNCommitClient svnCommitClient = svnClientManager.getCommitClient();
svnCommitClient.doCommit(new File[]{new File("project/README.txt")}, false, "Commit message", null, null, false, false, SVNDepth.INFINITY); 

我得到以下異常:

Exception in thread "main" org.tmatesoft.svn.core.SVNException: svn: E200009: Commit failed (details follow):
svn: E200009: 'D:\Java\xml2selenium-saas\POC\SvnKit\project\README.txt' is not under version control

提示我做錯了什么,我想看一個如何做的例子

歡迎來到Stackoverflow,

就像異常已經告訴你的那樣,你想要提交的文件還沒有受版本控制,所以你必須先添加它。

在你的CommitEditor你應該調用這樣的東西:

   SVNRepository repository = SVNRepositoryFactory.create( SVNURL.parseURIDecoded( url ) );

   ISVNEditor editor = repository.getCommitEditor( logMessage , null /*locks*/ , true /*keepLocks*/ , null /*mediator*/ );

   //the second and the third parameters are the path and revision respectively 
   //of the item's ancestor if the item is being added with history
   editor.addFile( "your/path/project/README.txt" , null , -1 );

您還應該看一下SVNKit的完整示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM