0

我想使用 SVNKit(版本 1.7)将一个服务器目录内容(版本化目录的所有版本化内容已经存在于服务器目录上)提交到同一服务器上的一个新目录。

这个新目录可能已经存在;或者必须根据绝对路径在适当的位置添加/制作它。(向服务器添加新目录我可以做)

但我无法将源路径内容提交到目标路径(已经存在或新创建的)。

我明白,因为我希望服务器到服务器提交,在这里,不会有任何工作副本。

我检查了在没有本地结帐的情况下通过 SVNKit 提交更改的文件中提到的解决方案? 但无法使其工作,因为我没有得到什么应该是源路径和什么应该是目标路径。

作为一种解决方法,我尝试了复制功能,但正如你所知,通过复制,文件的早期历史将被保留......我正在寻找在源路径到目标路径的所有内容的新版本。

我尝试的另一件事是在 c:// 驱动器上制作临时本地工作副本,将代码从源代码检出到该本地目录,然后将其提交到目标路径。但这不是适当的方式:(另外,我无法删除本地临时工作coopy;它说它包含root,因此无法删除。

任何人都可以帮助我使用 SVNKit 进行服务器到服务器的提交吗?

谢谢。-阿迪亚

4

1 回答 1

0

那不是那么困难。如果要保留复制历史记录,可以运行以下代码

ISVNCommitEditor editor = svnRepository.getCommitEditor("", null);

editor.openRoot(latestRevision);
editor.openDir("path", latestRevision); //or use addDir if it doesn't exist
editor.openDir("path/to", latestRevision); //or use addDir if it doesn't exist
editor.openDir("path/to/new", latestRevision); //or use addDir if it doesn't exist
editor.addDir("path/to/new/directory", "/path/to/old/directory", copySourceRevision); 
editor.closeDir();
editor.closeDir();
editor.closeDir();
editor.closeDir();
editor.closeDir();
editor.closeEdit();

但是如果你不想保留历史,你可以创建编辑器

ISVNCommitEditor editor = svnRepository.getCommitEditor("", null);

然后打电话

anotherSvnRepository.setLocation(copySourceUrl, true);
anotherSvnRepository.update(copySourceRevision, "", SVNDepth.INFINITY, false, reporter, customEditor);

而不是reporter使用此代码:

    ISVNReporterBaton reporter = new ISVNReporterBaton() {
        @Override
        public void report(ISVNReporter reporter) throws SVNException {
            reporter.setPath("", null, copySourceRevision, SVNDepth.INFINITY, true);
            reporter.finishReport();
        }
    }; 

customEditor应该是editor上面构造的包装器,它将editor使用正确的路径调用(也许您应该添加一些 openDir/closeDir 调用以使编辑器调用正确)。

例如,您可以查看我的svnkitfilter项目的源代码,该项目执行类似的操作。

要了解目录/文件是否存在,请使用 SVNRepository#checkPath 方法。

于 2013-09-16T13:12:47.653 回答