Saptarshi Purkayastha, an OpenMRS GSoC student this year, wrote mini java script and submitted a patch for adding the OpenMRS license to all of our java files. This was long overdue and was much appreciated, thanks Saptarshi!

Submitting this to trunk was no trouble at all, all things went as normal. However, when merging from trunk to other branches, I kept running into problems. All files that received the new license were showing as conflicts, even though there were no other changes. I had to manually copy the license from the old file to merged file. NOT fun. I did this manually when I was merging to the report-api-refactoring branch because it was late and I didn’t want to look up the “right” way to fix it.

Well, I think I found the reason.  Java file handlers don’t do prepending very well.  The script that Saptarshi wrote creates a new file with the license code, and then appends the old file contents.  The java newLine() method used in the java script to append that old file contents apparently uses a different newline character than the default for unix/windows.

This minor little difference caused two problems: 1) merging produced conflicts and 2) when comparing versions or showing annotations it showed that I had changed all lines when in fact I had just added the license header.

The fix for problem 1 above was to merge from trunk with the ignore-eol-style flag set:

svn merge -x––ignore-eol-style -r3684:3685 /home/ben/workspace/openmrs-api-refactoring

Note: I merged from trunk up to version 3684 first using the Subclipse svn gui (3685 was the revision with the license patch).  I ran the above at the command line to get a nice clean successful merge.  I was then able to merge from 3685 to HEAD using subclipse again.

I can’t really tell if this fixed problem 2 as well because I can’t remember which files this was happening to before.  The few files I queried were only showing me as having changed the first few license lines, so it appears to have solved it.

This is in the openmrs category tagged as , ,