git-p4 迁移不同子目录下的分支
git-p4 migrate branches in different subdirectories
我想将源代码树从 perforce 迁移到 git。源代码包含几个分散在 perforce depot 中的开发分支,不一定在同一个目录中。例如结构是这样的 -
//depot/dev/project/master
//depot/dev/project/branch1
//depot/dev/project/branch2
//depot/dev/sub-project/branch3
//depot/dev/sub-project/branch4
//depot/patch-project/branch5
//depot/patch-project/special/developern/branch6
我查看了 git-p4 文档 https://git-scm.com/docs/git-p4 BRANCH DETECTION section and also similar articles http://forums.perforce.com/index.php?/topic/1395-git-p4-and-multiple-branches/。
我可以为直系父级下的那些迁移历史分支
//depot/dev/project/branch1 and
//depot/dev/project/branch2
我无法实现的是如何一次将所有六个分支一起迁移。
我在指定分支规范后尝试运行在 //depot@all 级别上进行迁移,但是由于 perforce 服务器很大,它失败了,它给出了 maxresults 异常或会话超时。有人可以指导如何处理这种情况吗?
我看到的另一个选择是单独迁移分支(一个分支到一个 git 存储库),然后将所有分支合并到一个新的 git 存储库中。我不确定这样做会是什么 impact/downside。
Thanks and Regards,
Amar Kumbhar.
最新版本的 git-p4 不应报告 maxresults 异常,因为它将一次检索最多 500 个更改。您可以尝试使用 --changes-block-size
参数修改此值,这可能会帮助您解决您报告的问题。
下面是这个参数的说明,可以看出here:
--changes-block-size <n>::
The internal block size to use when converting a revision
specifier such as '@all' into a list of specific change
numbers. Instead of using a single call to 'p4 changes' to
find the full list of changes for the conversion, there are a
sequence of calls to 'p4 changes -m', each of which requests
one block of changes of the given size. The default block size
is 500, which should usually be suitable.
我之前遇到过类似的问题,就我而言,我必须找到一种解决方法,这就是您描述的方法,我将每个分支克隆到它自己的 Git 存储库中。
即便如此,各个分支的对象也太多了,P4 管理员不愿意提高所请求对象的限制,所以我还必须限制我克隆的历史记录数量。
对于非活动分支,我只会克隆最新版本并丢弃其所有历史记录。
对于更活跃的分支,我会保留 4-6 周的历史记录。
这意味着您必须手动计算出您要保留的历史记录量的 CL 编号:
来自 git-p4
文档(部分:DEPOT PATH SYNTAX):
$ git p4 clone //depot/my/project@1,6 # Import only changes 1 through 6.
总结: 它有效,git-p4 是一个很棒的工具,非常智能,带有很多可配置选项。分散在仓库树中任何地方的多个 b运行ches 已成功迁移。我们需要 运行 在最高级别(最顶层)的 perforce 目录中导入,该目录涵盖所有子目录或感兴趣的 b运行 目录。为了高效操作,建议使用 --changesfile 选项,明确指定要导入的变更列表。也可以使用 git-p4.branchUser 和 git- p4.branchList 明确指定 b运行chspecs。
详细信息: 这里我展示了适合我的设置。可能有更好的方法来实现目标。
Perforce 仓库结构:(如问题所述)
Perforce 客户端: 这设置在最高(最顶层)p4 目录。这非常重要,否则 git-p4 可能会将变更列表(由于客户端视图而受到限制)排除为空提交。
//depot/... //myp4client/...
Perforce b运行chspecs: 我创建了一个 b运行chspec 涵盖了我所有的 b运行ches 依赖项(parent/child) 信息
$ p4 branch -o test1 | grep "//"
//depot/dev/project/master/... //depot/dev/project/branch1/...
//depot/dev/project/master/... //depot/dev/project/branch2/...
//depot/dev/project/branch1/... //depot/dev/sub-project/branch3/...
//depot/dev/project/branch1/... //depot/dev/sub-project/branch4/...
//depot/dev/project/master/... //depot/patch-project/branch5/...
//depot/patch-project/branch5/... //depot/patch-project/special/developern/branch6
git-p4 配置项: 接下来,我设置一个空的 git 存储库和以下配置项。
mkdir workdir
cd workdir
git init
(** 强制变量)
git config git-p4.user myp4user
git config git-p4.passwowrd myp4password
git config git-p4.port myp4port
git config git-p4.client myp4client
(** 强制使用 perforce 客户端规范)
git config git-p4.useClientSpec true
git config git-p4.client myp4client
( ** 限制探索 b运行chspecs 仅由我创建)
git config git-p4.branchUser myp4user
( ** b运行ch信息,依赖关系,有趣的是只需要提到姓氏(b运行ch路径中的目录名),git-p4自动detects/pick 需要什么,即完全扩展 b运行ch 名称)
git config git-p4.branchList master:branch1
git config --add git-p4.branchList master:branch2
git config --add git-p4.branchList branch1:branch3
git config --add git-p4.branchList branch1:branch4
git config --add git-p4.branchList master:branch5
git config --add git-p4.branchList branch5:branch6
更改列表文件: 接下来,我收集了所有更改列表,对于我正在迁移的所有 b运行ches。
p4 changes //depot/dev/project/master/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/dev/project/branch1/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/dev/project/branch2/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/dev/sub-project/branch3/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/dev/sub-project/branch4/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/patch-project/branch5/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/patch-project/special/developern/branch6/... | cut -d' ' -f2 >> master.txt
sort -n master.txt | uniq > master_sorted.txt
导入: 最后我 运行 导入如下,我使用 "sync" 而不是克隆。
cd workdir
../git-p4.py sync //depot/... --detect-branches --verbose --changesfile /home/myp4user/master_sorted.txt
在较小的软件仓库上“ ../git-p4.py sync //depot@all --detect-b运行ches --verbose “应该也可以,在这种情况下不需要创建更改列表文件(前面的步骤)
导入完成后,我可以看到 git-p4 在单个 git 存储库中创建了所有远程 perforce b运行ches。
git branch -a
remotes/p4/depot/dev/project/master
remotes/p4/depot/dev/project/branch1
remotes/p4/depot/dev/dev/project/branch2
remotes/p4/depot/dev/dev/sub-project/branch3
remotes/p4/depot/dev/dev/sub-project/branch4
remotes/p4/depot/patch-project/branch5
remotes/p4/depot/patch-project/special/developern/branch6
然后我从远程 p4 b运行ches
创建了本地 b运行ches
git checkout -b master remotes/p4/depot/dev/project/master
git checkout -b branch1 remotes/p4/depot/dev/project/branch1
git checkout -b branch2 remotes/p4/depot/dev/dev/project/branch2
git checkout -b branch3 remotes/p4/depot/dev/dev/sub-project/branch3
git checkout -b branch4 remotes/p4/depot/dev/dev/sub-project/branch4
git checkout -b branch5 remotes/p4/depot/patch-project/branch5
git checkout -b branch6 remotes/p4/depot/patch-project/special/developern/branch6
接下来我简单地添加了一个远程源并将代码推送到 git 存储库中。
感谢 Whosebug 和在线提供的各种 pointers/help。
我想将源代码树从 perforce 迁移到 git。源代码包含几个分散在 perforce depot 中的开发分支,不一定在同一个目录中。例如结构是这样的 -
//depot/dev/project/master
//depot/dev/project/branch1
//depot/dev/project/branch2
//depot/dev/sub-project/branch3
//depot/dev/sub-project/branch4
//depot/patch-project/branch5
//depot/patch-project/special/developern/branch6
我查看了 git-p4 文档 https://git-scm.com/docs/git-p4 BRANCH DETECTION section and also similar articles http://forums.perforce.com/index.php?/topic/1395-git-p4-and-multiple-branches/。
我可以为直系父级下的那些迁移历史分支
//depot/dev/project/branch1 and
//depot/dev/project/branch2
我无法实现的是如何一次将所有六个分支一起迁移。
我在指定分支规范后尝试运行在 //depot@all 级别上进行迁移,但是由于 perforce 服务器很大,它失败了,它给出了 maxresults 异常或会话超时。有人可以指导如何处理这种情况吗?
我看到的另一个选择是单独迁移分支(一个分支到一个 git 存储库),然后将所有分支合并到一个新的 git 存储库中。我不确定这样做会是什么 impact/downside。
Thanks and Regards,
Amar Kumbhar.
最新版本的 git-p4 不应报告 maxresults 异常,因为它将一次检索最多 500 个更改。您可以尝试使用 --changes-block-size
参数修改此值,这可能会帮助您解决您报告的问题。
下面是这个参数的说明,可以看出here:
--changes-block-size <n>::
The internal block size to use when converting a revision
specifier such as '@all' into a list of specific change
numbers. Instead of using a single call to 'p4 changes' to
find the full list of changes for the conversion, there are a
sequence of calls to 'p4 changes -m', each of which requests
one block of changes of the given size. The default block size
is 500, which should usually be suitable.
我之前遇到过类似的问题,就我而言,我必须找到一种解决方法,这就是您描述的方法,我将每个分支克隆到它自己的 Git 存储库中。
即便如此,各个分支的对象也太多了,P4 管理员不愿意提高所请求对象的限制,所以我还必须限制我克隆的历史记录数量。
对于非活动分支,我只会克隆最新版本并丢弃其所有历史记录。
对于更活跃的分支,我会保留 4-6 周的历史记录。
这意味着您必须手动计算出您要保留的历史记录量的 CL 编号:
来自 git-p4
文档(部分:DEPOT PATH SYNTAX):
$ git p4 clone //depot/my/project@1,6 # Import only changes 1 through 6.
总结: 它有效,git-p4 是一个很棒的工具,非常智能,带有很多可配置选项。分散在仓库树中任何地方的多个 b运行ches 已成功迁移。我们需要 运行 在最高级别(最顶层)的 perforce 目录中导入,该目录涵盖所有子目录或感兴趣的 b运行 目录。为了高效操作,建议使用 --changesfile 选项,明确指定要导入的变更列表。也可以使用 git-p4.branchUser 和 git- p4.branchList 明确指定 b运行chspecs。
详细信息: 这里我展示了适合我的设置。可能有更好的方法来实现目标。
Perforce 仓库结构:(如问题所述)
Perforce 客户端: 这设置在最高(最顶层)p4 目录。这非常重要,否则 git-p4 可能会将变更列表(由于客户端视图而受到限制)排除为空提交。
//depot/... //myp4client/...
Perforce b运行chspecs: 我创建了一个 b运行chspec 涵盖了我所有的 b运行ches 依赖项(parent/child) 信息
$ p4 branch -o test1 | grep "//"
//depot/dev/project/master/... //depot/dev/project/branch1/...
//depot/dev/project/master/... //depot/dev/project/branch2/...
//depot/dev/project/branch1/... //depot/dev/sub-project/branch3/...
//depot/dev/project/branch1/... //depot/dev/sub-project/branch4/...
//depot/dev/project/master/... //depot/patch-project/branch5/...
//depot/patch-project/branch5/... //depot/patch-project/special/developern/branch6
git-p4 配置项: 接下来,我设置一个空的 git 存储库和以下配置项。
mkdir workdir
cd workdir
git init
(** 强制变量)
git config git-p4.user myp4user
git config git-p4.passwowrd myp4password
git config git-p4.port myp4port
git config git-p4.client myp4client
(** 强制使用 perforce 客户端规范)
git config git-p4.useClientSpec true
git config git-p4.client myp4client
( ** 限制探索 b运行chspecs 仅由我创建)
git config git-p4.branchUser myp4user
( ** b运行ch信息,依赖关系,有趣的是只需要提到姓氏(b运行ch路径中的目录名),git-p4自动detects/pick 需要什么,即完全扩展 b运行ch 名称)
git config git-p4.branchList master:branch1
git config --add git-p4.branchList master:branch2
git config --add git-p4.branchList branch1:branch3
git config --add git-p4.branchList branch1:branch4
git config --add git-p4.branchList master:branch5
git config --add git-p4.branchList branch5:branch6
更改列表文件: 接下来,我收集了所有更改列表,对于我正在迁移的所有 b运行ches。
p4 changes //depot/dev/project/master/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/dev/project/branch1/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/dev/project/branch2/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/dev/sub-project/branch3/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/dev/sub-project/branch4/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/patch-project/branch5/... | cut -d' ' -f2 >> master.txt
p4 changes //depot/patch-project/special/developern/branch6/... | cut -d' ' -f2 >> master.txt
sort -n master.txt | uniq > master_sorted.txt
导入: 最后我 运行 导入如下,我使用 "sync" 而不是克隆。
cd workdir
../git-p4.py sync //depot/... --detect-branches --verbose --changesfile /home/myp4user/master_sorted.txt
在较小的软件仓库上“ ../git-p4.py sync //depot@all --detect-b运行ches --verbose “应该也可以,在这种情况下不需要创建更改列表文件(前面的步骤)
导入完成后,我可以看到 git-p4 在单个 git 存储库中创建了所有远程 perforce b运行ches。
git branch -a
remotes/p4/depot/dev/project/master
remotes/p4/depot/dev/project/branch1
remotes/p4/depot/dev/dev/project/branch2
remotes/p4/depot/dev/dev/sub-project/branch3
remotes/p4/depot/dev/dev/sub-project/branch4
remotes/p4/depot/patch-project/branch5
remotes/p4/depot/patch-project/special/developern/branch6
然后我从远程 p4 b运行ches
创建了本地 b运行ches git checkout -b master remotes/p4/depot/dev/project/master
git checkout -b branch1 remotes/p4/depot/dev/project/branch1
git checkout -b branch2 remotes/p4/depot/dev/dev/project/branch2
git checkout -b branch3 remotes/p4/depot/dev/dev/sub-project/branch3
git checkout -b branch4 remotes/p4/depot/dev/dev/sub-project/branch4
git checkout -b branch5 remotes/p4/depot/patch-project/branch5
git checkout -b branch6 remotes/p4/depot/patch-project/special/developern/branch6
接下来我简单地添加了一个远程源并将代码推送到 git 存储库中。
感谢 Whosebug 和在线提供的各种 pointers/help。