安装Perforce服务:
存放服务器的根目录:/home/perforce
,里面包含p4
,p4d
两个文件
安装步骤如下:
- 设置服务器端口号为:1666
export P4PORT=1666
- 设置用户perforce
export P4USER=perforce
- 设置p4编码格式为 UTF-8
export P4CHARSET=utf8
- 在当前文件夹
/home/perforce
中启动Perforce服务器
./p4d -r `pwd` -J journal -L log -d
- 服务器设置为 Unicode 编码格式
./p4d -r `pwd` -xi
- 查看此时服务器的基本信息
./p4 info
- 初始化角色
./p4 user
- 初始化角色身份
./p4 protect
- 查看默认存在的存储库
./p4 depots
- 在路径
/home/workspace/
中创建工作区,并指定其名称为workspace
:
mkdir /home/workspace/
cd /home/workspace/
/home/perforce/p4 client workspace
# Client workspace saved.
- 查看工作区:
p4 clients
# Client workspace 2020/10/28 root /home/workspace/ 'Created by perforce. '
至此,服务端的基本操作准备就绪,至于安装步骤详情可查阅之前的文章,接下来开始配置p4convert工具环境
使用p4convert
工具来执行svn版本迁移:
-
获得svn转储文件
dumpfile
:svnadmin dump -r 0:3000 local_file_dir > dumpfile
使用svnadmin指令必须在安装svn的服务器上执行,这里取前三千的版本号制作转储文件到dumpfile中
PS:
svnrdump dump
命令不可用,通过它获得的转储文件为--delats
格式,不被p4convert工具识别 -
下载
p4convert
工具中的p4convert.jar
(包含在p4convert.zip
中):下载地址 -
执行
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 版本,其他版本会报错,下载地址
-
将
p4convert.jar
和dumpfile
放入/home/p4convert/
中 -
使用
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指南》
-
运行
java -jar p4convert.jar --config=default.cfg
开始执行转储程序。
补充:
- 这里的客户端工作区作用:存放dumpfile中导入的文件,并模拟svn提交的过程生成提交日志
- 运行结束后客户端工作区会自动清理
- 端口号那里需要通过
\
转义 - 远程连接记得开放 1666 端口