使用p4convert工具实现svn版本迁移至Perforce

安装Perforce服务:

存放服务器的根目录:/home/perforce,里面包含p4,p4d两个文件

安装步骤如下:

  1. 设置服务器端口号为:1666
export P4PORT=1666
  1. 设置用户perforce
export P4USER=perforce
  1. 设置p4编码格式为 UTF-8
export P4CHARSET=utf8
  1. 在当前文件夹/home/perforce中启动Perforce服务器
./p4d -r `pwd` -J journal -L log -d
  1. 服务器设置为 Unicode 编码格式
./p4d -r `pwd` -xi
  1. 查看此时服务器的基本信息
./p4 info
  1. 初始化角色
./p4 user
  1. 初始化角色身份
./p4 protect
  1. 查看默认存在的存储库
./p4 depots
  1. 在路径/home/workspace/中创建工作区,并指定其名称为workspace
mkdir /home/workspace/
cd /home/workspace/
/home/perforce/p4 client workspace
# Client workspace saved.
  1. 查看工作区:
p4 clients
# Client workspace 2020/10/28 root /home/workspace/ 'Created by perforce. '

至此,服务端的基本操作准备就绪,至于安装步骤详情可查阅之前的文章,接下来开始配置p4convert工具环境

使用p4convert工具来执行svn版本迁移:

  1. 获得svn转储文件dumpfile

    svnadmin dump -r 0:3000 local_file_dir > dumpfile
    

    使用svnadmin指令必须在安装svn的服务器上执行,这里取前三千的版本号制作转储文件到dumpfile中

    PS: svnrdump dump命令不可用,通过它获得的转储文件为--delats格式,不被p4convert工具识别

  2. 下载p4convert工具中的p4convert.jar(包含在p4convert.zip中):下载地址

  3. 执行java -jar p4convert.jar指令,得到:

    usage: java -jar p4convert.jar
     -c,--config <arg>    Use configuration file
     -d,--default         Generate a configuration file
     -e,--extract <arg>   Extract a revision
     -E,--end <arg>       End revision, for incremental (SVN)
     -i,--info            Report on repository usage
     -r,--repo <arg>      Repository file/path
     -S,--start <arg>     Start revision, for incremental (SVN)
     -t,--type <arg>      SCM type (CVS | SVN)
        --tags <arg>      find tags to specified depth
        --tree <arg>      (with --info), display tree to specified depth
     -u,--users           List repository users
     -v,--version         Version string
    
    Example: standard usage.
             java -jar p4convert.jar --config=myFile.cfg
    
    Example: generate a CVS configuration file.
             java -jar p4convert.jar --type=CVS --default
    
    Example: report Subversion repository usage.
             java -jar p4convert.jar --type=SVN --repo=/path/to/repo.dump --info
    

    运行此工具需要的jre 版本为:

    java version “1.7.0_80”
    Java™ SE Runtime Environment (build 1.7.0_80-b15)
    Java HotSpot™ 64-Bit Server VM (build 24.80-b11, mixed mode)

    只能是 java 1.7.X 版本,其他版本会报错下载地址

  4. p4convert.jardumpfile 放入/home/p4convert/

  5. 使用java -jar p4convert.jar --type=SVN --default指令得到default.cfg 配置文件,修改结果如下:

    # P4Convert configuration (Tue Oct 27 13:35:43 CST 2020)
    
    # Please note that all paths should be absolute and must end with a path
    # delimiter e.g. '/' or '\\'.  For example:
    #   com.p4convert.p4.clientRoot=C:\\perforce\\client_ws\\
    #   com.p4convert.p4.clientRoot=/Users/perforce/client_ws/
    
    # Core converter settings
    com.p4convert.core.schema=5.59
    com.p4convert.core.scmType=SVN
    com.p4convert.core.test=false
    com.p4convert.core.version=PUBLIC.Main.15706
    
    # Subversion import options
    com.p4convert.svn.dumpFile=/home/p4convert/dumpfile
    com.p4convert.svn.keepKeyword=true
    com.p4convert.svn.labelDepth=2
    com.p4convert.svn.labelFormat=svn_label:{depth}
    com.p4convert.svn.labels=false
    com.p4convert.svn.mergeInfoEnabled=false
    com.p4convert.svn.propEnabled=false
    com.p4convert.svn.propEncoding=ini
    com.p4convert.svn.propName=.svn.properties
    com.p4convert.svn.propTextType=UNKNOWN
    
    # Perforce Environment
    com.p4convert.p4.caseMode=NONE
    com.p4convert.p4.charset=utf8
    com.p4convert.p4.client=workspace
    com.p4convert.p4.clientRoot=/home/workspace
    com.p4convert.p4.depotPath=depot
    com.p4convert.p4.downgrade=false
    com.p4convert.p4.end=0
    com.p4convert.p4.jnlIndex=0
    com.p4convert.p4.jnlPrefix=jnl.
    com.p4convert.p4.lineEnding=true
    com.p4convert.p4.logRevID=<description>
    com.p4convert.p4.lowerCase=false
    com.p4convert.p4.mode=IMPORT
    com.p4convert.p4.normalisation=NFC
    com.p4convert.p4.offset=0
    com.p4convert.p4.passwd=
    com.p4convert.p4.port=localhost\:1666
    com.p4convert.p4.root=/home/perforce/
    com.p4convert.p4.skipEmpty=false
    com.p4convert.p4.start=1
    com.p4convert.p4.subPath=/
    com.p4convert.p4.translate=true
    com.p4convert.p4.unicode=false
    com.p4convert.p4.user=perforce
    
    # Logging options
    com.p4convert.log.audit.enabled=true
    com.p4convert.log.audit.filename=audit.log
    com.p4convert.log.changeMap=changeMap.txt
    

    每一行的代码解释请查看之前的文章:《p4convert指南》

  6. 运行java -jar p4convert.jar --config=default.cfg 开始执行转储程序。

补充:

  • 这里的客户端工作区作用:存放dumpfile中导入的文件,并模拟svn提交的过程生成提交日志
  • 运行结束后客户端工作区会自动清理
  • 端口号那里需要通过\转义
  • 远程连接记得开放 1666 端口
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值