有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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>

共 (2) 个答案

  1. # 2 楼答案

    好的,多亏了我的一个聪明的队友,我找到了解决办法。1.8.11版本中似乎有一个bug,不允许保存评论。 我在pom中更改了版本。xml到1.7.5,它的工作原理与任何东西一样

    代码没有改变。可能对其他正在为同一问题苦苦挣扎的人有所帮助