Patch Submission - LuxRender Wiki
Luxrender GPL Physically Based Renderer

Patch Submission

Personal tools

From LuxRender Wiki

Revision as of 15:28, 8 July 2012 by Darkstar (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

After you have obtained the source code, made changes to it, built and tested it (and included your tests in your patch, if possible), you'll want to get your changes reviewed and checked in. In order to do that, you need to create a file listing the changes you made, called a patch or a diff file. You can generate it using hg diff command.

Note that if you want to contribute your change, you will be asked to generate the diff against the latest version of the code (also known as head or the tip of an active branch for some patches).


Creating a diff of a single file

In order to create a diff of a single local file against the current file in the repository, use:

$ hg diff -p -U 8 FILENAME

This creates a diff in the so called 'unified' format (-U), with 8 lines of context. The diff is printed to stdout by default. To redirect the output to a file, use something like:

$ hg diff -p -U 8 FILENAME > OUT_FILE

Creating a diff for multiple files

If, instead of using a regular file for FILENAME, you provide a directory, then this directory as well as all subdirectories will be searched recursively. For example

$ hg diff -p -U 8 <sourceDirectory/restOfPath> > OUT_FILE

will compare all files in the current directory and all its subdirectories against the versions in the repository, and write the combined unified diffs to a file named OUT_FILE, using 8 lines of context.

There should be enough context in the patch for it to be understood without opening the source file. The default guideline is to use 8 lines of context; if more context is required to make the patch understandable, replace 8 with a higher number. Also note that the more context you include, the greater the chance to be able to also apply the patch to a file which differs heavily from the original source against which the diff was prepared.

Including new files in a patch

Don't forget to

$ hg add FILENAME

any new files you are adding before generating the patch.

Patches with lots of whitespace changes

When generating a patch you can ask diff to ignore whitespace changes. This is especially useful if you are doing a lot of indentation changes, such as when wrapping or unwrapping parts of the code inside if statements. To create a patch without whitespace changes use the -w flag. So if you use:

$ hg diff -p -U 8 <sourceDirectory/restOfPath> > OUTFILE

for your original patch, then do another patch with

$ hg diff -p -U 8 -w <sourceDirectory/restOfPath> > OUTFILE-w

When doing so, please make sure that both patches are attached to the bug (the patch without -w is needed for the reviewer to check that whitespace changes are done correctly and for the person doing the check-in for you to apply your changes).

Creating a patch using TortoiseHg

TortoiseHG is a Windows GUI front end for Mercurial. To create a patch go to the TortoiseHG Workbench and select the option.