I generated a patch some time ago using the p4 diff
command.
However, now that I want to apply it, I realize that there is no way to apply a patch in Perforce.
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.
What are my options ? Are there patch converters, or some Perforce extension allowing the application of these kind of patchs ?
Just found your question after saving some of my changes in a patch and reverting them in order to test some of the original code...
Assuming you're using a decent terminal emulator, this one time operation could take you up to an hour or so.
The good thing is that you can't run into this on a daily basis, as you probably will now use "-du" from now on, at least me I'm sure I will. Just copy and paste the file name as prompted:
Perhaps you will have 100 files in the patch... keep clicking :-)
If you're looking for a subst expression (vim, sed):
But - beware if you added sources (whole files, p4 add) their content probably won't be printed in the diff - in which case nobody will be able to re-patch them in...
Another answer:The
p4 diff2
command supports a-u
flag to generate diffs in GNU diff format.From
p4 help diff2
:Perhaps Perforce's diff output format has changed, but @RumburaK's answer didn't work for me.
I had to modify it to convert the
====
header to diff's+++
and---
header format.infile.txt was generated with the following command (where 12335 was a shelved changelist):
p4 describe -du -S 12345
outfile.txt was applied with the following command:
patch -p3 -l < outfile.txt