【问题标题】:commit one server dir contents to other directory using svnkit使用 svnkit 将一个服务器目录内容提交到另一个目录
【发布时间】:2013-09-20 11:27:06
【问题描述】:

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

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

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

我明白了,因为我希望 Server to server commit ,这里不会有任何工作副本。

我检查了Committing changed file via SVNKit without local checkout? 中提到的解决方案 但无法让它工作,因为我没有得到什么应该是源路径和什么应该是目标路径。

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

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

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

谢谢。 -阿迪亚

【问题讨论】:

    标签: svn commit svnkit


    【解决方案1】:

    这并不难。如果你想保留复制历史,你可以运行以下代码

    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 方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-17
      • 1970-01-01
      • 2011-09-07
      • 1970-01-01
      • 2011-01-04
      • 1970-01-01
      • 2020-09-06
      相关资源
      最近更新 更多