Blogs
I spent some time understanding the patching tool and I found that the patching tool's store option is very useful when it comes to comparing patches with custom modules.
Use case :
You have Liferay Portal instance with fixpack say liferay-fix-pack-de-89-7010.zip and hot fix say liferay-hotfix-7477-7010.zip. And now you come across a scenario where you found a liferay bug. You raise a ticket to Liferay and Liferay provides a hotfix on top of your current stack.
So say Liferay has provided the hotfix "liferay-hotfix-7478-7010.zip" which contains a fix for the bug you reported to Liferay.
Now to apply this patch you can simply use Liferay's patching tool to do so. I am not gone list steps here since you have good documentation provided by Liferay or you might be knowing by now :)
So far so good. Till now we have not considered the scenario where you have a custom module which is trying to override the Liferay's sources.
So now let's bring back this scenario. I have developed a module to override the OOTB Asset Publisher's view.jsp
When Liferay provided the liferay-hotfix-7478-7010.zip, it contains changes in sources as compared to liferay-hotfix-7477-7010.zip.
Now it is easy to apply a new patch with a patching tool. But wait, what about your custom changes. You copied the sources for your custom development or I would say your base source for custom development was a complaint to the source of hotfix "liferay-hotfix-7477-7010.zip"
There might be a possibility that Liferay's hotfix (liferay-hotfix-7478-7010.zip) has modified the OOTB Asset Publisher's view.jsp
So now for your custom development to be compliant with this hotfix you need to consider the view.jsp provided by liferay-hotfix-7478-7010.zip as the base source.
We consider only one scenario but in the actual project, we have many such modules. And now to check their complaint it's a nightmare job.
Solution :
Till I guess 6.2 or 6.1, Patching-tool's list-collisions use to do the job. In order to achieve this in DXP, we need a few more steps which are as follows
1) We assume that you have all your custom changes deployed and you have installed fix pack "liferay-fix-pack-de-89-7010-src.zip" along with hotfix "liferay-hotfix-7477-7010.zip"
2) Now you need to store your current state in order to make it available later to compare. so run below command
patching-tool.bat store add <descriptive-name>
patching-tool.bat store add dxp70-fix-89-with-hotfix-7477
This will take some time. Also, one thing to note here is that in the patches folder you have to make sure that you are using fixpack zip which contains sources as well.
So whenever you download the fixpack from liferay's site make sure you download with the source. For example, in our scenario, it would be liferay-fix-pack-de-89-7010-src.zip
It is well present in dropdown provided by Liferay during download.
3) With step 2, our current state is saved as "dxp70-fix-89-with-hotfix-7477" under patching-tool's store folder.
4) We now install the hotfix liferay-hotfix-7478-7010.zip
5) We then run below command to capture the collisions with respect to our custom plugins if any
patching-tool.bat diff collisions html dxp70-fix-89-with-hotfix-7477
This will generate the diff in Html format since we mention "html". The output HTML is stored in patching-tool's diff folder.
Few important points to note here are that collisions option work with only one parameter of stored state like "dxp70-fix-89-with-hotfix-7477" we provided in the above command. However, to capture the differences between two patches we can store the state of both the patches post applying and then compare with
patching-tool.bat diff html dxp70-fix-89-with-hotfix-7477 dxp70-fix-89-with-hotfix-7478
So to compare two patches,
You apply patch1 and store state
patching-tool.bat store add state1
You now apply patch2 and store state
patching-tool.bat store add state2
Now to compare,
patching-tool.bat diff html state1 state2
You might come across memory issues while running above command so to avoid you can edit patching-tool.bat/sh and update memory parameter to run the patching-tool.jar