Bugzilla:Patches

From MozillaWiki
Jump to navigation Jump to search

After you've written your code, the next thing to do is to make a patch! This is a file that will show exactly what changes you made to Bugzilla or its documentation, in a format that we can review and integrate into our codebase.

We also call patches "diffs", because one program used for making patches is called "diff".

Using CVS

If you installed Bugzilla from the tarball, it's already set up so that you can make diffs against CVS. This is the preferred way of making patches.

1. Change to your Bugzilla directory:

 cd /var/www/html/bugzilla

2. Make the patch by doing:

 cvs diff -Nu > patch.diff

3. You now have a file called patch.diff! It includes all your changes to Bugzilla, but it doesn't include any brand-new files that you added. You can add them to the patch by doing:

 diff -Nu /dev/null new-file-name >> patch.diff

Where new-file-name is the name of the file you added.

Using diff

Sometimes, for various reasons, you can't use CVS. In this case, you can get the difference between two Bugzilla directories, one which contains the base Bugzilla, and one which contains your modified Bugzilla.

Here's how to use diff to make a patch:

1. Change to your Bugzilla directory:

 cd /var/www/html/bugzilla

2. Now, Bugzilla contains lots of things that you don't want to diff, like the localconfig file and the data/ directory. So you want to exclude all of those from your diff. Here's a command that will do that:

 diff -Nru --exclude=data --exclude='*.orig' --exclude=CVS --exclude=localconfig --exclude=.htaccess --exclude='.#*' --exclude='*.rej' old/ new/ > patch.diff

Where old/ is the base Bugzilla before your modifications, and new/ is the Bugzilla that you modified.

3. Your patch is now in the file patch.diff.

If you make your patch this way, note that you made it this way when you attach it. (It makes a difference for the reviewer reading it and applying it.)