Monday, November 30, 2009

SVN Patch

I recently come across the 'Patch' feature of SVN and found it to be a very useful tool in several development scenarios. SVN patch feature is basically exporting the changes you have made to your source code in to a zip/patch file. It will contain all SVN meta data in addition to the files and you can apply the patch from a different place/machine to the same source code base. Some of the situations I feel a patch is useful are;

1. As a mean of code review / Collaborative Development

Code reviews don't necessarily have to happen as a meeting. The reviewee can pack his changes as a svn patch and email it to the reviewer who can check it in the context of the current code base and do necessary adjustments and commit it. This is more suited when the reviewer is someone from the same team and most probably a senior person in the team.

I've heard that lot of open source projects use this feature to make sure that the commits coming from all around the world are in line with the quality of the code base.

2. When working on top of another developers code base

Many consultants and senior team members have to work on other developer code bases (and machines) sometimes. This is specially true for consultants. Sometime a fix or a change has to be done on top of a an already uncommited changes in the code base. Then the best thing to do is to create a patch from the changes you just did and then revert the changes in the code base. Then you can just apply the patch only. That way you are not altering the external developer code base but still can get u'r local changes in to SVN.

The same scenario is useful when u need to get in a quick fix on top of a not so solid code base which is under serious change.
Post a Comment