SVNKit:将同一文件夹中不同线程的文件添加到SVN失败

时间:2017-05-17 14:30:29

标签: svn concurrency commit svnkit

我们正在尝试使用SVNKit将同一文件夹中不同线程的不同文件添加到SVN。我们正在使用低级SVNKit API(SVNRepository和ISVNEditor)

代码如下所示,它是从多个线程同时调用的,

ISVNEditor editor = svnRepository.getCommitEditor("example modification", null, true, null);
    editor.openRoot(-1);
    editor.openDir(parentPath, -1);
    System.out.println(String.format("Opened dir %s for commit of file %s", parentPath, svnfilePath ));
    if(!isFilePresent)
    {
        editor.addFile(svnfilePath, null, -1);
        System.out.println(String.format("Added file %s", svnfilePath ));
    }
    else
    {
        editor.openFile(svnfilePath, -1);
        System.out.println(String.format("Opened file %s", svnfilePath ));
    }
    editor.applyTextDelta(svnfilePath, null);
    final SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
    InputStream             inputStream    = new FileInputStream(sourcePath.toFile());

    final String            checksum       = deltaGenerator.sendDelta(svnfilePath, inputStream, editor, true);
    editor.closeFile(svnfilePath, checksum);
    editor.closeDir();
    editor.closeDir(); //close the root
    SVNCommitInfo commitInfo = editor.closeEdit();

我们正在追踪异常,

org.tmatesoft.svn.core.SVNException: svn: E160024: File or directory 'test' is out of date; try updating
svn: E160024: version resource newer than txn (restart the commit)
svn: E175002: CHECKOUT of '/svn/temp/!svn/ver/6435/test': 409 Conflict (http://XXXXXXXXXX.com:444)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:112)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:96)
at org.tmatesoft.svn.core.internal.io.dav.DAVCommitEditor.checkoutResource(DAVCommitEditor.java:631)
at org.tmatesoft.svn.core.internal.io.dav.DAVCommitEditor.addFile(DAVCommitEditor.java:304)

那么我们如何使用SVNKit同时添加多个文件。我们希望避免同步添加,因为许多用户可以同时添加新文件。

0 个答案:

没有答案