如何在 Windows 中运行 git-p4?

发布于 2024-08-29 00:41:12 字数 70 浏览 4 评论 0 原文

git-p4 看起来不像是 Windows 的 MSys-Git 项目的一部分。有谁知道如何让它在 Windows 上运行吗?

It doesn't look like git-p4 is part of the MSys-Git project for Windows. Does anybody know how to get it running through Windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

归途 2024-09-05 00:41:12

2019 年 7 月更新,Git P4 克隆损坏”问题现在由 加布里埃尔·莫兰

[alias]
    p4 = !python.exe 'c:\\program files\\Git\\mingw64\\libexec\\git-core\\git-p4'

然后从命令行使用 git p4 就可以了。


在 Git 2.32(2021 年第 2 季度)中,git p4 学会了更有效地查找分支点。

请参阅 提交 6b79818提交 c3ab088(2021 年 5 月 5 日),作者:Joachim Kuebart (jkuebart
(由 Junio C Hamano -- gitster -- 合并于 提交 e289f68,2021 年 5 月 14 日)

git-p4:加快搜索速度分支父级

签字人:Joachim Kuebart
帮助者:Junio C Hamano
帮助者:卢克·迪亚曼德

对于 git-p4 导入的每个新分支,它需要找到从其父分支分支出来的提交。
虽然 p4 没有显式记录此信息,但分支上的第一个更改列表通常是父分支的相同副本。

方法 searchParent() 尝试在给定“父”分支的历史记录中查找提交,其树与新分支“target”的初始变更列表完全匹配>”。
该代码迭代父提交,并使用 diff-tree 将每个提交与此初始更改列表进行比较。

由于我们已经知道要查找的树对象名称,因此为每次提交生成 diff-tree 是浪费的。

使用“rev-list”的“--format”选项查找历史记录中每个提交的树对象名称,并找到其所在的树name 与目标提交的树完全相同,以对此进行优化。

这会带来相当大的加速,至少在 Windows 上是这样。
在一台具有相当大的存储库(父分支中有大约 16000 次提交)的 Windows 计算机上,当前代码需要 7 分钟多的时间,而对于相同的更改列表,新代码只需要 10 多秒:

之前:

$ 时间 git p4 同步
从/到多个分支导入
仓库路径://depot
导入修订版 31274 (100.0%)
更新分支:b1

真实7分41.458秒
用户0m0.000s
系统0m0.077s

之后:

$ 时间 git p4 同步
从/到多个分支导入
仓库路径://depot
导入修订版 31274 (100.0%)
更新分支:b1

真实0米10.235秒
用户0m0.000s
系统0m0.062s


更新 2020 年 3 月

使用 Git 2.27(2020 年第 2 季度),“git p4” 已更新为可与 Python 3 配合使用。

请参阅 提交 6bb40ed(2020 年 1 月 23 日),作者:SZEDER Gábor (szeder)
请参阅 提交 7575f4f提交 ce425eb, 提交2e2aa8d提交a6b1306提交4294d74提交 50da1e7提交 5a5577d提交d38208a提交86dca24提交 6cec21a , 提交 1f8b46d, commit 0b4396f(2019 年 12 月 13 日),作者: 杨昭(yangminz
请参阅 提交 484d09c(2019 年 12 月 13 日),作者:Ben Keene (seraphire)
(由 Junio C Hamano -- gitster -- 合并于 提交 9a0fa17,2020 年 3 月 25 日)

ci:在linux-gcc中使用python3以及其他地方的 osx-gcc 和 python2

签字人:SZEDER Gábor

Python2 已结束生命周期,我们一直在准备 Python 脚本以与 Python3 配合使用。

'git p4',Python 的主要 in-tree 用户,刚刚收到了一些兼容性更新。

仅在 Git 2.30(2021 年第 1 季度)的 commit 263dc0 中记录了这一点。


2018 年 7 月更新:

Git 2.19(2018 年第 3 季度)将开始为 git p4 带来 Python 3 支持。

请参阅提交 db2d997提交 f2606b1, 提交efdcc99提交 4d88519提交 dba1c9d提交 fc35c9d(2018 年 6 月 19 日),作者:Luke Diamand (luked99)
(由 Junio C Hamano -- gitster -- 合并于 提交 6dcd364,2018 年 7 月 18 日)

代码准备,使“git p4”更接近可用于 Python 3。


年 1 月更新:

自 2010 年以来,contrib/fast-import/git-p4.README 自 2012 年 4 月起提及

git-p4 脚本移至顶层git 源目录的。
请注意,顶级 git-p4.py 脚本现在是源

Windows 用户可以直接复制 git-p4.py 源脚本,可能
通过同一文件夹中名为“git-p4.bat”的批处理文件调用它。
它应该只包含一行:

@python "%~d0%~p0git-p4.py" %*

尽管这个 2013年文章直接调用git-p4.py


原始答案(2010年4月)

正如“为什么 Perforce 比 Git 更具可扩展性",请注意不要在 Git 中导入任何 p4 存储库。 Git 无法处理 P4 可以管理的同类大型独特存储库。

Git-P4 在 Python 中,它应该在 Windows 上运行(就像这个问题< /a>)

你可以在这里获取 git-p4.py 并将其用作 git-p4.bat

@python "%~d0%~p0git-p4" %*

它需要安装 Python 2.x。

不要忘记还有另一种方法

Update July 2019, the "Git P4 clone broken" question now mentions by Gabriel Morin:

[alias]
    p4 = !python.exe 'c:\\program files\\Git\\mingw64\\libexec\\git-core\\git-p4'

Then using git p4 from the command line worked.


With Git 2.32 (Q2 2021), git p4 learned to find branch points more efficiently.

See commit 6b79818, commit c3ab088 (05 May 2021) by Joachim Kuebart (jkuebart).
(Merged by Junio C Hamano -- gitster -- in commit e289f68, 14 May 2021)

git-p4: speed up search for branch parent

Signed-off-by: Joachim Kuebart
Helped-by: Junio C Hamano
Helped-by: Luke Diamand

For every new branch that git-p4 imports, it needs to find the commit where it branched off its parent branch.
While p4 doesn't record this information explicitly, the first changelist on a branch is usually an identical copy of the parent branch.

The method searchParent() tries to find a commit in the history of the given "parent" branch whose tree exactly matches the initial changelist of the new branch, "target".
The code iterates through the parent commits and compares each of them to this initial changelist using diff-tree.

Since we already know the tree object name we are looking for, spawning diff-tree for each commit is wasteful.

Use the "--format" option of "rev-list" to find out the tree object name of each commit in the history, and find the tree whose name is exactly the same as the tree of the target commit to optimize this.

This results in a considerable speed-up, at least on Windows.
On one Windows machine with a fairly large repository of about 16000 commits in the parent branch, the current code takes over 7 minutes, while the new code only takes just over 10 seconds for the same changelist:

Before:

$ time git p4 sync
Importing from/into multiple branches
Depot paths: //depot
Importing revision 31274 (100.0%)
Updated branches: b1

real    7m41.458s
user    0m0.000s
sys     0m0.077s

After:

$ time git p4 sync
Importing from/into multiple branches
Depot paths: //depot
Importing revision 31274 (100.0%)
Updated branches: b1

real    0m10.235s
user    0m0.000s
sys     0m0.062s

Update March 2020

With Git 2.27 (Q2 2020), "git p4" is updated to work with Python 3.

See commit 6bb40ed (23 Jan 2020) by SZEDER Gábor (szeder).
See commit 7575f4f, commit ce425eb, commit 2e2aa8d, commit a6b1306, commit 4294d74, commit 50da1e7, commit 5a5577d, commit d38208a, commit 86dca24, commit 6cec21a, commit 1f8b46d, commit 0b4396f (13 Dec 2019) by Yang Zhao (yangminz).
See commit 484d09c (13 Dec 2019) by Ben Keene (seraphire).
(Merged by Junio C Hamano -- gitster -- in commit 9a0fa17, 25 Mar 2020)

ci: use python3 in linux-gcc and osx-gcc and python2 elsewhere

Signed-off-by: SZEDER Gábor

Python2 reached end of life, and we have been preparing our Python scripts to work with Python3.

'git p4', the main in-tree user of Python, has just received a number of compatibility updates.

This is documented only with Git 2.30 (Q1 2021) in commit 263dc0.


Update July 2018:

Git 2.19 (Q3 2018) will start bringing Python 3 support to git p4.

See commit db2d997, commit f2606b1, commit efdcc99, commit 4d88519, commit dba1c9d, commit fc35c9d (19 Jun 2018) by Luke Diamand (luked99).
(Merged by Junio C Hamano -- gitster -- in commit 6dcd364, 18 Jul 2018)

Code preparation to make "git p4" closer to be usable with Python 3.


Update January 2016:

Since 2010, contrib/fast-import/git-p4.README mentions since April 2012

The git-p4 script moved to the top-level of the git source directory.
Note that the top-level git-p4.py script is now the source

Windows users can copy the git-p4.py source script directly, possibly
invoking it through a batch file called "git-p4.bat" in the same folder.
It should contain just one line:

@python "%~d0%~p0git-p4.py" %*

(Although this 2013 article is invoking git-p4.py directly)


Original answer (April 2010)

As mention in "Why Perforce is more scalable than Git", be careful to not import in Git any p4 repo. Git cannot handle the same kind of huge unique repo P4 can manage.

Git-P4 being in Python, it should run on Windows (like in this question)

You can grab git-p4.py here and use this as git-p4.bat

@python "%~d0%~p0git-p4" %*

It requires a Python 2.x installed.

Don't forget there is another approach as well.

迟到的我 2024-09-05 00:41:12

我发现的最简单的答案,到目前为止似乎工作完美,是在 Timo Geusch 的博客

  • 确保您已安装 Python 2.X,例如在 C:\Python27 中(不知道 if git-p4 支持 Python 3,所以我没有冒险 git-p4。 py 不支持 Python 3.X,截至 2014 年 3 月)
  • 从任何地方获取 git-p4.py 的副本,例如,正如 Eric Lathrop 的博客文章所建议的,从 git repo 直接(我从我碰巧已经设置好的 git 2.1 linux 安装中获得了我的)
  • 在您的 MSysGit 安装中,导航到 libexec\git-core,例如,在 Windows 7 64 位上安装的 Git for Windows 1.9.4-preview20140611 上,即 C:\Program Files ( x86)\Git\libexec\git-core
  • 将 git-p4.py 文件拖放到那里
  • 在同一位置,编辑“git-p4”无扩展名文件,将虚拟 echo 和退出行替换为单行

    c:/python27/python "c:/program files (x86)/Git/libexec/git-core/git-p4.py" $1 $2 $3 $4 $5 $6 $7 $8 $9

就是这样。 git-p4 现在可以在 Windows 安装的 MSysGit / Git 上运行,就像在任何 Linux 机器上一样。

(请注意,Eric Lathrop 的现有答案有很多关于使用 git-p4 及其所有限制的附加信息;我我认为这个问题可以从一个简单的如何回答实际问题中受益,即轻松地让它在 Windows 上工作,以免更多的流浪者像我上周一样灰心丧气)

The simplest answer I found, and seems to work flawlessly so far, was on Timo Geusch's blog:

  • Make sure you have Python 2.X installed, eg in C:\Python27 (dunno if git-p4 supports Python 3, so I didn't risk it git-p4.py does not support Python 3.X, as of March 2014)
  • Get a copy of git-p4.py from anywhere, eg as Eric Lathrop's blog post suggests, from the git repo directly (I got mine from a linux install of git 2.1 that I happened to have already set up)
  • In your MSysGit installation, navigate to libexec\git-core, eg on my Git for Windows 1.9.4-preview20140611 install on windows 7 64-bit that is C:\Program Files (x86)\Git\libexec\git-core
  • Drop your git-p4.py file there
  • At that same location, edit the "git-p4" extensionless file, replacing the dummy echo and exit lines with a single line

    c:/python27/python "c:/program files (x86)/Git/libexec/git-core/git-p4.py" $1 $2 $3 $4 $5 $6 $7 $8 $9

That's it. git-p4 now works on your MSysGit / Git for Windows installation just like it does on any linux box.

(please note, Eric Lathrop's existing answer has a lot of additional information about working with git-p4 and all its limitations; I thought this question could benefit from a simple howto answer to the actual question though, i.e. easily getting it working on Windows, lest more wanderers be discouraged as I was last week)

遇见了你 2024-09-05 00:41:12

我让它发挥了作用,但这是一个漫长而艰巨的过程,充满了危险。我在博客上写下了说明: http ://ericlathrop.com/2012/12/how-to-set-up-git-p4-in-windows/

I got it to work, but it was a long, arduous process, fraught with peril. I wrote up the instructions on my blog: http://ericlathrop.com/2012/12/how-to-set-up-git-p4-in-windows/

池予 2024-09-05 00:41:12

阅读后 https://git-scm.com/docs/git-p4

 py -2 "C:\Program Files\Git\mingw64\libexec\git-core\git-p4" clone //Projects/App/@all

为我

After reading https://git-scm.com/docs/git-p4

 py -2 "C:\Program Files\Git\mingw64\libexec\git-core\git-p4" clone //Projects/App/@all

Worked for me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文