SVN模型仓库中的资源从一个地方移动到另一个地方的办法(很久才解决)
来源:互联网 发布:淘宝严重违规包括那些 编辑:程序博客网 时间:2024/04/29 07:27
弄了很久,想使用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[1]; copySources[0] = 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; } }}
0 0
- SVN模型仓库中的资源从一个地方移动到另一个地方的办法(很久才解决)
- Java实现文本、图片、视频的拷贝(从一个地方拷贝到另一个地方)
- 利用Java代码实现把一个文件从一个地方剪切到另一个地方
- Java 练习把一个文件从一个地方剪切到另一个地方
- 黑马程序员--把一个多层目录结构的文件夹复制到另一个地方
- 一个下载资源的好地方
- 从一个git仓库提交代码到另一个git仓库
- 推荐一个CG模型的下载地方。
- 收集到一个下载电子书的地方
- 关于从四个方向往一个地方移动后碰撞往后小退的代码
- 将SVN仓库里面的一个文件夹的所有内容复制到另一个文件夹下
- 关于信号槽连接地方的一点心得,一个问题困扰了一下午才解决,纪念一下。
- 从某些地方粘贴中文到plsql,中文变成乱码的解决
- chrome浏览器安装离线的插件--是百度很久才搜索到的办法
- 从svn上拷贝一个项目到另一个svn
- 从SVN到git仓库的移植
- 将select中的项从一个移动到另一个select中
- RCP:如何把Preferences中的项从一个类别移动到另一个类别
- Eclipse扩展点实践之添加快捷菜单项(Command方式实现)
- (转)一篇很不错的介绍Eclipse插件Menu及其扩展点的文章
- Eclipse扩展点实践之添加菜单项(ActionSet方式实现)
- SVN的svnlook命令
- SWT中在treeview中显示图片
- SVN模型仓库中的资源从一个地方移动到另一个地方的办法(很久才解决)
- String的split
- SVN的switch命令
- SVNKIT的low api应用之修改库中文件内容(File modification)
- SVNKIT的SVNCommitClient的doMkDir的操作
- 关于结构体中如何计算的问题
- 将svnkit转成dlls时的问题
- 开源软交换系统 FreeSwitch 与 Asterisk 比较
- Java对Xml进行操作的实例(转)