-- Oyvind Bakksjo Sun Microsystems, Database Technology Group Trondheim, Norway http://weblogs.java.net/blog/bakksjo/
Title: Committing patches
Committing patches to the Derby Subversion Repository
Committing contributions from others is not as straightforward as one
might think. This mainly stems from the fact that there is an svn diff command, but there is no svn patch command (lack of symmetry - see this and this Subversion issue). There are a number of things to remember; if not
done carefully, you might end up doing partial commits that may break
the build. This page attempts to give a recipe for safely committing
code contributions.
- Make sure you have a clean sandbox:
- In the
trunkdirectory, runsvn status- it should not list anything. If it does, you may want to runsvn revert -R .to remove all local modifications, or use/check out a different sandbox. - Run
ant clobber.
- In the
- Check your sandbox' svn revision with
svn info. - Align you sandbox' svn revision with the patch's.
- If the contributor has indicated on which revision the patch was created (with
svn diff), runsvn update -r REVISION. - Otherwise, you may choose to run
svn update -r { DATE }, using the date of the contribution of the patch. NOTE: svn is very picky about date formats. See http://svnbook.red-bean.com/en/1.0/ch03s03.html and scan down for valid date formats. - If you think there has been no changes in the patch's area since it was contributed, you can try on the head:
svn update.
- If the contributor has indicated on which revision the patch was created (with
- Apply the patch in the
trunkdirectory:patch -p0 < PATCH_FILE. - Make sure there were no conflicts when applying the patch. On unix, you can run
find . -name "*.rej" -print. If a*.rejfile is found, you should either resolve the conflict or ask the submitter to submit a new patch against the newest revision. If you omit this step, you'll still catch this problem before committing (when you compare yoursvn statusoutput to the contributor's), but it's a good idea to catch this early on. - Run
svn status - Newly added files will show up with
?, indicating that Subversion does not know anything about them. You will have to add these yourself usingsvn add. - You will have to set svn properties for added files. In particular for all text files. Run
svn propset svn:eol-style native FILE(S). If you have your subversion configuration setting this should be done automatically. Add this list to your~/.subversion/configfile, as described in http://www.apache.org/dev/version-control.html. - Now compare your sandbox to the contributor's: run
svn status | diff - CONTRIBUTOR'S_SVN_STATUS_FILE. This should be clean, except that the ordering may be different. You can overcome this by sorting both your ownsvn statusoutput and the contributor's file withsortbefore comparing:svn status | sort > MY_SVN_STATUS_FILE; cat CONTRIBUTOR'S_SVN_STATUS_FILE | sort | diff - MY_SVN_STATUS_FILE.- If the svn status output was made on Windows vs. Unix, you may need to adjust formatting such as spacing and forward versus backward slashes.
- If the diff contains new, empty files,
patchwill not create them for you; you will have to create them yourself usingtouch FILENAME.- After creating such new, empty files, you will have to add them, too, with
svn add(and set the correct svn properties).
- After creating such new, empty files, you will have to add them, too, with
- By now your
svn statusshould be equal to the contributor's. Now compare the diff by runningsvn diff | diff - PATCH_FILE. - The diffs you see could be the following:
- Revision numbers, if your sandbox was not aligned with the contributor's (see above)
- Subversion file properties: You will have to set svn properties for added files (see above). Do not automatically take for granted the properties in the contributor's patch file, he/she may have got it wrong; use your own judgement.
- Actual code diffs: Inspect and figure out what/why.
- Files may be examined in different order by
svn diffon your machine and the contributor's; not sure if there's anything we can do about that.
- Files may be examined in different order by
- Update to the head with
svn update. Check that there are no conflicts. - Build the code with
ant allandant buildjars. - Run tests if you are not confident that the contributor's/reviewer's actions are sufficient.
- Check that tests pass. If they do not:
- Check the nightly/tinderbox for the same failure.
- Verify that the failure is not caused by the patch.
- Check that tests pass. If they do not:
- Commit the patch with
svn commit. Use either--message,--fileor--editor-cmd- Include the following in the commit message:
- The ID of the JIRA issue. Make sure you use the format DERBY-NNN so that JIRA picks it up.
- Some text explaining what the patch does (typically snipped from the JIRA issue).
- The contributor's name/email.
- Include the following in the commit message:
- Send out an email to let people know you have committed the patch.
