将多个分支从Perforce迁移到Git

时间:2017-06-01 14:46:21

标签: git perforce git-p4

我尝试使用git-p4工具将perforce存储库迁移到Git,但是在分支配置上苦苦挣扎。考虑以下P4布局:

Folder1/
-- SubFolder1/
-- SubFolder2/
Folder2/
file1.txt
file2.txt

在这里,我需要将SubFolder1和SubFolder2作为单独的分支迁移,同时保留Folder2,file1&主分支中的file2。

我尝试在p4.branchList config中指定以下配置:

git config --add git-p4.branchList DEPOT_PATH/Folder1/SubFolder1:Branch1
git config --add git-p4.branchList DEPOT_PATH/Folder1/SubFolder2:Branch2
git config --add git-p4.branchList DEPOT_PATH/Folder1:master

但是我收到了这个错误并没有多大帮助:

p4 describe -s 521710 did not return 1 result: [{'generic': 33, 'code': 'error', 'data': "Operation 'user-describe' failed.\nChange 521705 description missing!\n", 'severity': 4}, {'p4ExitCode': 1}]

我很确定我做错了什么,我甚至不确定git-p4是否可以进行当前的布局迁移。任何帮助将不胜感激。

由于

更新

我忘了提到我尝试运行p4 describe命令,如错误消息中所示,但我收到另一个错误,指出"更改描述丢失"。

1 个答案:

答案 0 :(得分:1)

说实话,我并不完全确定可以做你想做的事。 假设每个分支都位于完整的独立目录结构中,而不是在子目录下,实现了分支检测。

但是,您不应该在该配置中使用库路径。这些目录对始终与导入过程中使用的原始库路径相关。请注意,每对应该是integrate(或类似)操作的源和目标目录。也就是说,假设您具有以下结构:

//depot/project/main
//depot/project/branch1
//depot/project/branch2

分支是使用:

创建的
p4 integrate //depot/project/main //depot/project/branch1
p4 integrate //depot/project/branch1 //depot/project/branch2

然后,您需要在使用git p4 clone //depot/project/...@all导入时配置以下分支:

git config --add git-p4.branchList main:branch1
git config --add git-p4.branchList branch1:branch2

因此,根据您的具体示例,如果您使用以下命令导入:

git p4 clone --detect-branches //depot/path/...@all

然后您只需要在 /path/部分之后包含路径。

假设DEPOT_PATH //depot/project_root和导入命令git p4 clone --detect-branches //depot/...@all,您需要以下配置:

git config --add git-p4.branchList project_root:project_root/Folder1/SubFolder1
git config --add git-p4.branchList project_root:project_root/Folder1/SubFolder2

也就是说,SubFolder1和SubFolder2都是从project_root集成的。