java SVN工具包提交注释问题
我正在使用SVNKIT提交SVN中的更改。它在java中运行良好,正如预期的那样。问题是评论没有保存在svn中。 我正在做下面的事情:
String comment = "testing here";
ISVNEditor editor = repository.getCommitEditor(comment, null /*locks*/ , false /*keepLocks*/ , null /*mediator*/ );
SVNCommitInfo commitInfo = modifyFile(editor, "", "filePath", contents, modifiedContents);
修改文件的方法如下所示
private static SVNCommitInfo modifyFile(ISVNEditor editor, String dirPath,
String filePath, byte[] oldData, byte[] newData) throws SVNException {
editor.openRoot(-1);
editor.openDir(dirPath, -1);
editor.openFile(filePath, -1);
editor.applyTextDelta(filePath, null);
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
String checksum = deltaGenerator.sendDelta(filePath, new ByteArrayInputStream(oldData), 0, new ByteArrayInputStream(newData), editor, true);
editor.closeFile(filePath, checksum);
editor.closeDir();
editor.closeDir();
return editor.closeEdit();
}
我找不到为什么评论没有被保存的错误。maven的条目也是一样的-
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.8.11</version>
# 1 楼答案
从SVNKIT 1.8.9开始,就支持Subversion1的短暂事务属性。8[参考https://subversion.apache.org/docs/api/1.8/group__Capabilities.html#gae1424ec62e198a77499726431c35ab6e]这是导致问题的原因。因此,使用1.8.9之前的任何SVNKIT版本都不应出现此错误。参考https://svn.svnkit.com/repos/svnkit/branches/1.8.x/CHANGES.txt了解SVNKIT在多个版本中所做的更改
# 2 楼答案
好的,多亏了我的一个聪明的队友,我找到了解决办法。1.8.11版本中似乎有一个bug,不允许保存评论。 我在pom中更改了版本。xml到1.7.5,它的工作原理与任何东西一样
代码没有改变。可能对其他正在为同一问题苦苦挣扎的人有所帮助