SVN模型仓库中的资源从一个地方移动到另一个地方的办法(很久才解决)
弄了很久,想使用domove这个操作,但是都失败了。最后给svnkit的邮箱写了封邮件,他们告诉我这样做就成功了。实际上是使用docopy这个函数实现了move操作。
package com.repositoryclient.svnoptions; import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.ISVNOptions;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNCopyClient;
import org.tmatesoft.svn.core.wc.SVNCopySource;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNWCUtil; public class StoreManagerCheckResourceOption { private SVNRepository repositoryTrgt;
private SVNRepository repositorySrc; public boolean doMove(String userName,String passwd,String sourceDirUrl,String targetDirUrl){
SVNClientManager ourClientManager;
// 初始化支持svn://协议的库
SVNRepositoryFactoryImpl.setup();
DAVRepositoryFactory.setup();
FSRepositoryFactory.setup();
SVNURL repositorySrcUrl = null;
SVNURL repositoryTrgtUrl = null; try {
SVNWCUtil.createDefaultAuthenticationManager(userName,passwd);
repositorySrcUrl = SVNURL.parseURIEncoded(sourceDirUrl);
repositoryTrgtUrl = SVNURL.parseURIEncoded(targetDirUrl);
repositorySrc = SVNRepositoryFactory.create(repositorySrcUrl);
repositoryTrgt = SVNRepositoryFactory.create(repositoryTrgtUrl);
ISVNAuthenticationManager authManager =SVNWCUtil.createDefaultAuthenticationManager(userName,passwd);
repositorySrc.setAuthenticationManager(authManager);
repositoryTrgt.setAuthenticationManager(authManager);
ISVNOptions options = SVNWCUtil.createDefaultOptions(false);
// 实例化客户端管理类
ourClientManager = SVNClientManager.newInstance(
(DefaultSVNOptions) options, userName, passwd);
SVNCopyClient copyClient = ourClientManager.getCopyClient();
SVNCopySource[] copySources = new SVNCopySource[];
copySources[] = new SVNCopySource(SVNRevision.HEAD, SVNRevision.HEAD, repositorySrcUrl); // SVNDirEntry entry = (SVNDirEntry) srcRepository.getDir(sourceDirUrl, -1, null, (Collection) null);
// if (entry.getKind() == SVNNodeKind.DIR) {
// copyClient.doCopy(copySources, repositoryTrgtUrl, true, false, false, "move", null);
// } else {
// copyClient.doCopy(copySources, repositoryTrgtUrl, true, false, true, "move", null);
// }
copyClient.doCopy(copySources, repositoryTrgtUrl, true, false, false, "move", null);
// SVNWCClient client = new SVNWCClient(authenticationManager, (ISVNOptions)(SVNWCUtil.createDefaultOptions(true)));
// SVNCommitInfo svnInfo = ourClientManager.getLogClient(). // 要把此目录的内容导入到版本库
// File sourceDir = new File(sourceDirUrl); // File targetDir = new File("relative/" + targetDirUrl);
// targetDir = targetDir.getAbsoluteFile();
// sourceDir.setReadable(true);
// targetDir.setWritable(true);
// 执行导入操作
// SVNMoveClient svnMoveClient = ourClientManager.getMoveClient();
// SVNUpdateClient svnUpdateClient = new SVNUpdateClient(authenticationManager, options);
// svnMoveClient.doVirtualCopy(sourceDir, targetDir, true);
// svnMoveClient.doMove(sourceDir, targetDir);
// svnUpdateClient.doRelocate(sourceDir, repositorySrcUrl, repositoryTrgtUrl, true);
return true;
} catch (SVNException e) {
// TODO: handle exception
e.printStackTrace();
return false;
}
}
}
SVN模型仓库中的资源从一个地方移动到另一个地方的办法(很久才解决)的更多相关文章
- WPF中的资源简介、DynamicResource与StaticResource的区别(转)
什么叫WPF的资源(Resource)?资源是保存在可执行文件中的一种不可执行数据.在WPF的资源中,几乎可以包含图像.字符串等所有的任意CLR对象,只要对象有一个默认的构造函数和独立的属性. 也就是 ...
- java 从jar包中读取资源文件
在代码中读取一些资源文件(比如图片,音乐,文本等等),在集成环境(Eclipse)中运行的时候没有问题.但当打包成一个可执行的jar包(将资源文件一并打包)以后,这些资源文件找不到,如下代码: Jav ...
- (转)java 从jar包中读取资源文件
(转)java 从jar包中读取资源文件 博客分类: java 源自:http://blog.csdn.net/b_h_l/article/details/7767829 在代码中读取一些资源文件 ...
- WPF中的资源简介、DynamicResource与StaticResource的区别
原文:WPF中的资源简介.DynamicResource与StaticResource的区别 什么叫WPF的资源(Resource)?资源是保存在可执行文件中的一种不可执行数据.在WPF的资源中,几乎 ...
- 将svn的项目转移到另外一个仓库中
前几天在做一个项目的时候,因为需要,需要将Server A 上SVN仓库 repos1中的项目pro1迁移到Server B 上的SVN仓库中,首先想到的是:通过复制,但是仔细一想,这样是不可能的:然 ...
- 克隆git仓库中的一个分支
克隆git仓库中的某一个分支,可用如下命令: git clone -b <branch_name> <repo> 如:git clone -b hdcp_ree_tee_dev ...
- eclipse多个项目保存到gitee上一个仓库中
自己练习创建到多个项目,想同步到gitee上一个仓库中. 1. 首先在gitee上创建项目springtest 2. 在eclipse默认项目存放到地方创建文件夹springtest,用来同步gite ...
- 将本地的一个新项目上传到GitHub上新建的仓库中去
转载: 如何将本地的一个新项目上传到GitHub上新建的仓库中去 踩过的坑: 1.在git push时报错 error: RPC failed; curl 56 SSL read: error:000 ...
- 如何将现有 git 仓库中的子项目单独抽出来作为一个独立仓库并保留其提交历史
很多时候,我们会遇到在一个git仓库下包含了很多小项目,但是随着有些项目的需求逐渐增大或则市场需求,我们需要将其抽离出来,作为一个单独的项目进行维护并开发. 但是,如果直接拷贝文件粘贴到新建的git ...
随机推荐
- linux 控制台使用技巧
1. 键盘无响应 可能是按下ctrl+s, 此时按下scroll即可解锁 2. 想看上一屏的信息 shift+pageup 3. 打印的信息和错误信息区分 普通信息, 用printf, cout打印的 ...
- 九度OnlineJudge之1020:最小长方形
题目描述: 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内. 输入: ...
- HTML5 input placeholder 颜色 改动
David Murdoch:Chrome支持input=[type=text]占位文本属性,但下列CSS样式却不起作用: CSS input[placeholder], [placeholder], ...
- ABAP常用字符串处理
1.SEARCH搜索指定字符串 REPORT Z_CHAR. ). MOVE 'Welcom to sap world!' to str. SEARCH str for 'sap'. 如果查找成功sy ...
- Html.Partial("")与Html.RenderPartial("")区别
文章有点长,但大多是代码,看看很快的,不要压力太大.网上有很多关于这两个方法的区别,都说出了它本质的区别(不看代码,只看这个结论,就已经足够了,如果觉得有必要从代码中得出这个结论,那就继续往下看),这 ...
- DELPHI 通過窗口句柄或窗口标题得到进程句柄
DELPHI 通過窗口句柄或窗口标题得到进程句柄2009年05月08日 星期五 10:15procedure TForm1.Button1Click(Sender: TObject);varhWind ...
- 【ASP.NET Web API教程】2.1 创建支持CRUD操作的Web API
原文 [ASP.NET Web API教程]2.1 创建支持CRUD操作的Web API 2.1 Creating a Web API that Supports CRUD Operations2.1 ...
- MySQL备份方案-->(利用mysqldump以及binlog二进制日志)
MySQL备份方案-->(利用mysqldump以及binlog二进制日志) 随着数据不 ...
- freemarker的TemplateExceptionHandler使用
系统使用freemarker作为页面展示层,为了解决系统统一异常的问题.于是配置了struts2的统一异常解决的方法(这个网上资料非常多,大家能够查看),但是发现freemarker出现异常后,str ...
- Android菜鸟的成长笔记(7)——什么是Activity
原文:[置顶] Android菜鸟的成长笔记(7)——什么是Activity 前面我们做了一个小例子,在分析代码的时候我们提到了Activity,那么什么是Activity呢? Activity是An ...