Can I apply changes from a perforce patch(downloaded from review board) to my code

1.2k views Asked by At

A colleague has created a perforce change list and has posted a review on review board for the change. Alas the change is not shelved, but I need to apply the change to my code. The colleague will not be available for some days so I can not ask him to shelve the files or to give me a unified diff of the files. So all I have now is the code review. From reviewboard I can download the perforce patch for the change. Please note this is not unified diff(like the output of p4 diff -du), but is some other format. Now my question is - is there a way I can apply this patch to another perforce client? Or maybe to convert the diff to unified diff so that I can use linux patch command?

1

There are 1 answers

0
user1411349 On

It's fairly straightforward to apply a patch file downloaded from reviewboard on to a copy of the source code.

The only thing that you need to change is the path to the source code.

So, for example, given a downloaded patch file which has lines like:

Index:getasset/env/getasset.global.settings.env
===================================================================
---  //grand/ats/main/getasset/env/getasset.global.settings.env //grand/ats/main/getasset/env/getasset.global.settings.env3#24
+++  //grand/ats/main/getasset/env/getasset.global.settings.env   (working copy)
@@ -59,5 +59,13 @@
 

You only need to change each line starting with +++.

You can either change it to an absolute path to your source code or a relative path from some starting dir.

Then you combine that with judicious use of -p and potentially -d and the patch file will apply.