我想提交一个修改过的单个文件。根据http://wiki.svnkit.com/Committing_To_A_Repository我使用以下代码:
public static SVNCommitInfo modifyFile(ISVNEditor editor, String dirPath, String filePath, InputStream is, long size) throws SVNException {
try {
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
editor.openRoot(-1);
editor.openDir(dirPath, -1);
editor.openFile(filePath, -1);
editor.applyTextDelta(filePath, null);
String chksm = deltaGenerator.sendDelta(filePath, is, editor, true);
editor.textDeltaEnd(filePath);
editor.closeFile(filePath, chksm);
/*
* Closes the directory.
*/
editor.closeDir();
/*
* Closes the root directory.
*/
editor.closeDir();
return editor.closeEdit();
} catch (SVNException e) {
if (editor != null) {
try {
editor.abortEdit();
} catch (Exception ex) {
}
}
throw e;
}
}
但不幸的是,尽管提交是由拥有外观的用户完成的,但我得到了一个例外:
org.tmatesoft.svn.core.SVNException: svn: E175002: PUT of '/spielwiese/!svn/wrk/e9019037-4201-0010-b534-277444c0b279/postcommittesten.txt': 423 Locked (http://localhost:8081)
svn: E175002: PUT request failed on '/spielwiese/!svn/wrk/e9019037-4201-0010-b534-277444c0b279/postcommittesten.txt'
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:106)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:90)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:739)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:369)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.performHttpRequest(DAVConnection.java:728)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.doPutDiff(DAVConnection.java:514)
at org.tmatesoft.svn.core.internal.io.dav.DAVCommitEditor.closeFile(DAVCommitEditor.java:335)
我错了什么?正确的方法是什么?
我尝试使用SVNCommitClient。但是 SVNCommitClient 需要一个本地工作副本来提交单个文件,我不想创建一个本地工作副本。所以我想直接将文件提交到给定位置的存储库中。
如何提交被当前用户锁定的文件?