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

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

问题描述

正如我在上一个问题中提到的,我是调查将我们的源代码控制从Perforce迁移到git。

环顾四周,我发现 git-p4 (你必须多挖一点,因为它甚至不在链接指向的存储库中。实际的 git-p4 script 很难找到)。

我现在正在运行这个脚本,它会在新的git仓库中导入当前版本的文件,但我无法设法获取历史记录,事关我的事。



以下是我使用的命令行:

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

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



谢谢!

joce。

解决方案

@all到文件路径。例如,这为我生成一个单一版本的回购:

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

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

  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在大型修改表(比如最初创建分支)时遇到了问题(尽管使用客户端规范可能有帮助,但是我没有认为我尝试了它)和文件与+ Sfiletype修饰符(这是坏和邪恶,但我们曾经使用它)。我的Python-fu不会让我解决我遇到的问题。



编辑:因为有人问它,在这里。



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



入门:

  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等。作为一种方式,我可以从那些被复制的特定分支中选择要传播到克隆的分支。

它会尝试检测分支是如何创建的,但这是无论如何与Perforce有点猜测。除此之外,它不会尝试进行任何分支跟踪:即使是整个分支合并也不会被这样写出来,对不起。

初始克隆,从git副本内部运行 p4-git-xfer fetch 将执行增量更新。高水位变化列表取自git回购中的 marks / p4 。这是一个快速导入加载的标记文件,所以如果您使用filter-branch重写某些特殊的脚步,请注意,您也可能需要更新它。



这不太好,有一些中等到严重的问题;我主要是为了我自己的方便使用它,将我自己从Perforce问题中分离出来,而不是将其作为日常的关键基础设施组件。这是单向的:我通常使用p4-am脚本来应用由 git format-patch 创建的补丁。这本身只适用于大多数情况,通常会解析nastiness,文件结束换行问题,二进制变化等。


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).

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/...

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.

Thanks!

joce.

解决方案

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

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.

EDIT: since someone asked for it, here it is.

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.

Getting started:

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

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.

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.

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.

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天全站免登陆