Difference between revisions of "Creating and Applying Patches"

From Opentaps Wiki
Jump to navigationJump to search
(Applying Patches)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
__TOC__
 +
 
= Creating Patches =
 
= Creating Patches =
 
__TOC__
 
  
 
== Patch of Changes that I Made ==
 
== Patch of Changes that I Made ==
Line 39: Line 39:
 
Let's say you want to create a patch against a specific revision of opentaps, such as the bugfix revision 9593.  In order to do this, you will need either a complete checkout of opentaps that's fully up to date or internet access to the opentaps subversion repository.  Since it's simpler to use the online opentaps subversion repository, we will go over this technique here.
 
Let's say you want to create a patch against a specific revision of opentaps, such as the bugfix revision 9593.  In order to do this, you will need either a complete checkout of opentaps that's fully up to date or internet access to the opentaps subversion repository.  Since it's simpler to use the online opentaps subversion repository, we will go over this technique here.
  
To make the patch, use the <tt>svn diff</tt> command and use the <tt>-c</tt> argument to specify the revision,
+
To make the patch, use the <tt>svn diff</tt> command and use the <tt>-c</tt> argument to specify the revision.  You must also specify the location of the opentaps repository from the trunk directory.  The full command is as follows,
  
 
<pre>
 
<pre>
Line 45: Line 45:
 
</pre>
 
</pre>
  
The file <tt>bugfix.patch</tt> is created and it contains a specific revision of the opentaps repository.
+
A file named <tt>bugfix.patch</tt> is created and it contains revision 9593 of opentaps.
 +
 
 +
= Applying Patches =
 +
 
 +
If you get a patch, you can use it to modify your files with the <tt>patch</tt> command.  patch is a standard UNIX command, and a [http://gnuwin32.sourceforge.net/packages/patch.htm Windows version] is also available.  First ensure that you are in the root directory of opentaps,
 +
 
 +
<pre>
 +
  prompt> cd opentaps
 +
</pre>
 +
 
 +
It should contain the build.xml and startofbiz.sh files.
 +
 
 +
We recommend copying the patch file to this directory for convenience.  For instance, if you have the <tt>bugfix.patch</tt> patch file from the above example, copy it into the opentaps root directory.  Also make sure the patch is not compressed (.zip or .gz).
 +
 
 +
Next, use the <tt>patch</tt> command with <tt>-p0</tt> arguments as follows,
 +
 
 +
<pre>
 +
  prompt> patch -p0 < bugfix.patch
 +
</pre>
 +
 
 +
If you did not copy the path file to the opentaps root directory, you will have to specify the full path to your patch file,
 +
 
 +
<pre>
 +
  prompt> patch -p0 < /path/to/bugfix.patch
 +
</pre>
 +
 
 +
Assuming you have made no major changes that would conflict with the patch, it should be applied without errors.  You can check to see if the patch was applied correctly using <tt>svn diff</tt>.
 +
 
 +
== Dealing with Patch Rejects ==
 +
 
 +
Sometimes the patch might fail to be applied to a certain file.  In this case, a rejection file is created with information about what caused the problem.  Rejection files have the same name and location as the file that was not patched, except that it has an extension <tt>.rej</tt>.

Latest revision as of 22:18, 2 October 2008

Creating Patches

Patch of Changes that I Made

To make a patch of the changes you made to opentaps, you can use the svn diff command from a terminal or command prompt.

First, ensure you are in the root directory of opentaps,

  prompt> cd opentaps

To verify that you're in the right directory, ensure that it contains the build.xml and startofbiz.sh files. Next, execute the svn diff command,

  prompt> svn diff

It will print the patch of all changes you made to the screen. To save the output to a file instead, use a redirect,

  prompt> svn diff > mychanges.patch

This command will create a mychanges.patch file that contains all changes you made to opentaps.

If you wish to see changes of only one file or directory, you can specify the file or directory explicitly,

  prompt> svn diff applications/product

This command will make a patch of all your changes to the applications/product/ directory and its children.

Patch of Specific Revision of Opentaps

Let's say you want to create a patch against a specific revision of opentaps, such as the bugfix revision 9593. In order to do this, you will need either a complete checkout of opentaps that's fully up to date or internet access to the opentaps subversion repository. Since it's simpler to use the online opentaps subversion repository, we will go over this technique here.

To make the patch, use the svn diff command and use the -c argument to specify the revision. You must also specify the location of the opentaps repository from the trunk directory. The full command is as follows,

  prompt> svn diff -c 9593 svn://svn.opentaps.org/opentaps/versions/1.0/trunk > bugfix.patch

A file named bugfix.patch is created and it contains revision 9593 of opentaps.

Applying Patches

If you get a patch, you can use it to modify your files with the patch command. patch is a standard UNIX command, and a Windows version is also available. First ensure that you are in the root directory of opentaps,

  prompt> cd opentaps

It should contain the build.xml and startofbiz.sh files.

We recommend copying the patch file to this directory for convenience. For instance, if you have the bugfix.patch patch file from the above example, copy it into the opentaps root directory. Also make sure the patch is not compressed (.zip or .gz).

Next, use the patch command with -p0 arguments as follows,

  prompt> patch -p0 < bugfix.patch

If you did not copy the path file to the opentaps root directory, you will have to specify the full path to your patch file,

  prompt> patch -p0 < /path/to/bugfix.patch

Assuming you have made no major changes that would conflict with the patch, it should be applied without errors. You can check to see if the patch was applied correctly using svn diff.

Dealing with Patch Rejects

Sometimes the patch might fail to be applied to a certain file. In this case, a rejection file is created with information about what caused the problem. Rejection files have the same name and location as the file that was not patched, except that it has an extension .rej.