使用 git-p4 获取整个文件历史记录 [英] Getting the whole files history with git-p4

查看:40
本文介绍了使用 git-p4 获取整个文件历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我在 上一个问题中提到的,我是考虑将我们的源代码控制从 Perforce 迁移到 git.
环顾四周,我发现 git-p4 (你必须挖一个更多,因为它甚至不在链接指向的存储库中.实际的 git-p4 脚本 更难找到).

As I've mentioned in a previous question, I'm looking into migrating our source control from Perforce to git.
Looking around, I've found git-p4 (you have to dig a bit more, since it's not even at the repository pointed by the link. The actual git-p4 script harder to find).

我现在正在运行这个脚本,它将文件的当前版本导入到一个新的 git 存储库中,但是无论我做什么,我都无法获取历史记录.

I'm now running this script, and it imports the current version of the files in a new git repository, but I can't manage to get the history, no matter what I do.

这是我当前使用的命令行:

Here's the current command line I use is:

P4CLIENT=my-p4-clientspec git-p4 clone --max-changes=1000 --use-client-spec //p4/path/to/be/imported/...

所以,真正的问题是:如果有人设法导入了 P4 仓库,包括历史,我想知道你是如何做到的.

So, the real question is: if anyone has managed to import a P4 depot, including the history, I'd like to know how you did it.

推荐答案

尝试将@all"附加到文件路径.例如,这会为我生成一个单一修订的 repo:

Try appending "@all" to the file path. For example, this produces a single-revision repo for me:

python /usr/share/doc/git-core/contrib/fast-import/git-p4 clone --destination=master-pom 
    //depot/services/master-pom/trunk/...

此命令导入了完整的历史记录:

This command imported the full history:

python /usr/share/doc/git-core/contrib/fast-import/git-p4 clone --destination=master-pom 
    //depot/services/master-pom/trunk/...@all

我尝试使用示例 git-p4 但由于几个原因放弃了并编写了自己的快速导入泵.很久以前了,所以现在可能已经修复了一些问题:但是 git-p4 在处理大型变更列表时遇到了问题(例如最初创建分支)(尽管使用客户端规范可能有帮助,但我没有想我试过了)和带有+S"文件类型修饰符的文件(这是Bad And Evil,但我们曾经使用它).而且我的 Python-fu 无法让我解决我遇到的问题.

I tried using the example git-p4 but gave up for several reasons and wrote my own fast-import pump. It was a while back, so some of the problems may have been fixed now: but git-p4 had trouble with large changelists (such as the initial creation of a branch) (although using the client spec may have helped, I don't think I tried it) and files with the "+S" filetype modifier (which is Bad And Evil, but we used to use it). And my Python-fu wasn't up to letting me fix the issues I had.

既然有人要了,就在这里.

since someone asked for it, here it is.

https://github.com/araqnid/p4utils 有几个 p4 的东西,其中 p4-git-xfer 是 p4->git(单向)复制器.但它有很多问题,因为它主要是一个个人方便的工具,而不是一个真正的基础设施.

https://github.com/araqnid/p4utils has several p4 things, of which p4-git-xfer is the p4->git (one-way) replicator. It has quite a few issues though, due to being mainly a personal handy-tool rather than a real piece of infrastructure.

开始:

p4-git-xfer clone -d $PWD/dictionary.git -n //depot/services/midoffice/dictionary/... 
  trunk 'release/*' 'branch/*' 
  trunk=master release/*=r* branch/*=dev/*

会将该 perforce 路径克隆到一个裸露的dictionary.git".基本路径之后的第一个参数是分支规范",它告诉复制器在哪里可以找到基本路径下的分支.后面的那些(带有'='符号)是镜像规范",它告诉复制器如何从导入的分支创建本地分支.分支规范导致refs/remotes/p4/trunk"、refs/remotes/p4/release/1.0"等被创建.镜像规范强制refs/heads/master"镜像refs/remotes/p4/trunk",refs/heads/r1.0"镜像refs/remotes/p4/release/1.0"等.作为一种允许我从复制的分支中选择特定分支以传播到克隆的方法.

will clone that perforce path to a bare "dictionary.git". The first arguments after the base path are "branch specs" that tell the replicator where to find branches under the base. The later ones (with '=' symbols) are "mirror specs" that tell the replicator how to create local branches from the imported ones. The branch specs cause "refs/remotes/p4/trunk", "refs/remotes/p4/release/1.0" etc. to be created. The mirror specs force "refs/heads/master" to mirror "refs/remotes/p4/trunk", "refs/heads/r1.0" to mirror "refs/remotes/p4/release/1.0" etc. It was intended as a way to allow me to select just particular branches from those that were replicated to get propagated to clones.

它会尝试检测分支是如何创建的,但对于 Perforce,这还是有点猜测.除此之外,它根本不会尝试进行任何分支跟踪:即使是全分支合并也不会这样写出来,抱歉.

It will attempt to detect how a branch is created, but that's a bit of a guess anyway with Perforce. Apart from that, it doesn't try to do any branch tracking at all: even whole-branch merges won't be written out as such, sorry.

在初始克隆之后,从 git 副本内部运行 p4-git-xfer fetch 将执行增量更新.高水位变更列表取自 git repo 中的 marks/p4.这是一个可以快速导入加载的标记文件,因此如果您使用 filter-branch 来重写东西等任何花哨的步骤,请注意您可能也必须更新它.

After the initial clone, running p4-git-xfer fetch from inside the git replica will do an incremental update. The high-water-mark changelist is taken from marks/p4 within the git repo. This is a marks file that fast-import loads, so if you do any fancy footwork like using filter-branch to rewrite things, beware you may have to update this too.

它不漂亮,并且有一些中度到严重的问题;我使用它主要是为了我自己的方便,将自己与 Perforce 问题隔离开来,而不是作为日常关键的基础设施组件.这是单向的:我通常使用 p4-am 脚本来应用由 git format-patch 创建的补丁.这本身仅在大多数情况下有效,一般解析令人讨厌,文件结尾换行符问题,二进制更改等.

It's not pretty, and has some medium-to-serious issues; I use it mainly for my own convenience, to isolate myself from Perforce problems, not as a day-to-day criticial infrastructure component. It's one-way: I generally use the p4-am script to apply patches created by git format-patch. That itself only works mostly, with general parsing nastiness, problems with end-of-file newlines, binary changes etc.

这篇关于使用 git-p4 获取整个文件历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆