Submitting patches

Patches for bug fixes, improvements and extension are welcomed and sought by the Naked Objects development team. The process is simple: get the latest code; make your changes; create a patch file; and email it to us. As most development is done within the Eclipse IDE that is the best place to create the patches, although patches created in other ways (as long as they following the standard structure) are fine too. We will look at using both Eclipse and Subversion here.

Getting the latest code

It is important that you make changes against the latest version of the development code so that it easier merge. Code that is easier to merge gets incorporated more quickly.

The latest version of the source can be checked out of the Subversion repository using the following command:

$ svn co http://nakedobjects.svn.sourceforge.net/svnroot/nakedobjects/framework/trunk nakedobjects

or, assuming you have already checked it out, then ensure that it up-to-date:

$ cd nakedobjects
$ svn up

Changing the code

Make the changes to your local copy ensuring that you use the same coding style and formatting (see code style for details and for the location of the Eclipse settings to assist you).

Creating the patch

A patch is just a special file that details what files are affected and what the changes are. This way a set of related changes can be grouped together and the size of the file is minimal.

Creating from within Eclipse

Creating a patch from within Eclipse can be done easily, but only if you are have one of the Subversion plug-ins installed and the project is shared (see the Team/Share... option).

From within Eclipse open up the contextual menu (right-click) on the file, package or project that has been changed and select the Team/Create Patch... option. In the dialog (shown below) that comes up specify a descriptive file name and confirm that all the files that are checked are the ones that you want to submit. Press the Finish button to create the patch file.

create-patch-dialog

Creating using Subversion

Subversion’s diff command will do a similar thing, but of course you need to use the command line. (You can also use other Subversion clients, such as Tortoise, but you need to find out which menu items correspond to the diff command). Use the following command with a specific project (as shown here), package or file identified to create the patch and redirect the output to a file. Here we are creating a patch for the whole of the runtime project and placing it in the file fixture-patch.txt.

$ svn diff core/runtime > fixture-patch.txt

NOTE – when using Subversion’s diff command only those files that are under Subversion’s control are included. Specifically new files are not part of that set until they have been added (using svn add). So to submit new files either add them with the appropriate svn command or submit them separately.

An example file

The result of this is a file like this (which has been truncated to save space):

Index: /home/rcm/no-development/workspace_DEV_4.0/nakedobjects/core/runtime/src/main/java/org/nakedobjects/runtime/fixture/ObjectFixtureService.java
===================================================================
--- /home/rcm/no-development/workspace_DEV_4.0/nakedobjects/core/runtime/src/main/java/org/nakedobjects/runtime/fixture/ObjectFixtureService.java	(revision 14471)
+++ /home/rcm/no-development/workspace_DEV_4.0/nakedobjects/core/runtime/src/main/java/org/nakedobjects/runtime/fixture/ObjectFixtureService.java	(working copy)
@@ -2,10 +2,12 @@

 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.Reader;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -28,6 +30,7 @@
 import org.nakedobjects.metamodel.spec.feature.OneToOneAssociation;
 import org.nakedobjects.metamodel.util.CollectionFacetUtils;
 import org.nakedobjects.runtime.context.NakedObjectsContext;
+import org.nakedobjects.runtime.fixturesinstaller.FixtureException;

 public class ObjectFixtureService {
@@ -55,6 +58,9 @@

         public NakedObject get(String data) {
             int pos = data.indexOf('#');
+            if (pos == -1) {
+                throw new FixtureException("read failed - object spec: " + data);
+            }
             String id = data.substring(pos + 1);
             NakedObject object = idMap.get(id);
             if (object == null) {

This was produced using Subversion. The file produced by Eclipse is the same except it has a couple of comments at the top, one of which indicates which project the changes come from.

Submitting the patch

Now simply email the patch to us. The email address is patches@nakedobjects.org. The subject line should start with the text PATCH: so that they are not picked out as Spam. Attach the files to the email and in the body explain what the patch is for and what changes it makes. This will help the developers assess the patches and apply them quickly. Please also ensure your email address is correct so that we can contact you if necessary.

When we receive a patch we will load it up using Eclipse and can immediately see what changes will be made. After checking the changes they will be applied to the code and checked in. If you have requested a response we will then email you to let you know what change has been applied.

No Comment

No comments yet

Leave a reply