如何应用Perforce补丁? [英] How to apply a Perforce patch?
问题描述
前段时间我使用 p4 diff
命令生成了补丁。
I generated a patch some time ago using the p4 diff
command.
但是,现在我想要要应用它,我意识到无法在Perforce中应用补丁。
However, now that I want to apply it, I realize that there is no way to apply a patch in Perforce.
因为我没有使用 -du
选项,该修补程序采用晦涩的perforce格式,不能与 patch(1)
一起应用。原始更改已丢失。另外,该补丁的长度超过300kb,因此手动编辑不是一个好选择。
Since I did not use the -du
option, the patch is in that obscure perforce format and can't be applied with patch(1)
. The original changes have been lost. Also, that patch is over 300kb long so manual editing isn't really an option.
我有什么选择?是否有补丁程序转换器或某些Perforce扩展程序允许应用这类补丁?
What are my options ? Are there patch converters, or some Perforce extension allowing the application of these kind of patchs ?
推荐答案
也许Perforce的diff输出格式已更改,但是@RumburaK的答案对我不起作用。
Perhaps Perforce's diff output format has changed, but @RumburaK's answer didn't work for me.
我必须对其进行修改以转换 ====
标头为diff的 +++
和 ---
标头格式。
I had to modify it to convert the ====
header to diff's +++
and ---
header format.
sed -Ee 's|==== (//.*)#[0-9]+(.*)|+++ \1\n--- \1|' < infile.txt > outfile.txt
infile.txt是使用以下命令生成的(其中12335是搁置的更改列表): p4 describe -du -S 12345
infile.txt was generated with the following command (where 12335 was a shelved changelist): p4 describe -du -S 12345
outfile.txt通过以下命令应用:补丁-p3 -l< outfile.txt
outfile.txt was applied with the following command: patch -p3 -l < outfile.txt
这篇关于如何应用Perforce补丁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!