Mike MacDonagh's Blog

Somewhere in the overlap between software development, process improvement and psychology

How to deal with line feeds in Jazz RTC SCM

I’ve found that there’s sometimes a bit of confusion over how Eclipse & RTC deal with line feeds, especially when migrating files from ClearCase so thought I’d post about it.

By default RTC tries to be helpful when opening text files on windows and linux platforms by rewriting the text file contents to either windows standard or linux standard depending on which platform you’re currently using. This is generally quite helpful as it means that when you load a workspace on whatever platform and use an external editor to mess around with text files they’re in the right format to make sense to your editor.

There are some cases when this behaviour isn’t quite so helpful however which can often come up during migration from ClearCase or other SCM tools. During migration you tend to copy a set of files from a location, change permissions on them and then stick them into a workspace for sharing into Jazz SCM. If you do this on windows then your files will be converted to windows format. As I said in the previous paragraph this is generally helpful but in some cases isn’t, as if the team generally develop on linux then when they load the files they’ll convert the format again making a change set which can interfere in a simple understanding of the history of files or when doing a file contents comparison.

Similarly if you build on windows and then deploy to linux and run some bash scripts or similar in your set of files you can hit problems as the files loaded on windows will be converted to windows format, if they’re copied to a server without running a dos2unix (or similar) conversion on them then the scripts won’t run on the target server.

There are a couple of features that you can use to prevent these problems, which although minor and easily corrected, can sometimes dent confidence in adopting teams. I’ve heard teams say they want exactly the same files (in binary terms) that they had in ClearCase and they don’t want RTC to rewrite to platform… that’s easily achievable you just need to fiddle with some settings. Of course other teams simply don’t notice as the apparent contents stay the same whatever platform you’re on.

My advice for avoiding these issues is:

  1. Set a sensible set of default file format options in Eclipse before starting (Window -> Preferences -> Team -> File Content) including setting to “binary” any file formats you don’t want to change such as .sh (unfortunately this doesn’t have a */other files setting)
  2. Do the migration on the normal development platform the team will use with a bias towards linux – My process for doing migrations
  3. Ensure the adopting team is aware of the difference between line feed settings on different platforms and knows how to change them in their project.

RTC provides features to work around line feed formats, if you right click on a project in project explorer you can select Team -> Change File Properties to change the properties of the files in your project.  The setting text/plain : platform indicates that RTC should rewrite files to the current platform, so setting .sh files delimiter to LF (Unix) will prevent problems in the previous scenario even if the  project is built and deployed on Windows. Choosing next on this wizard allows you to set general preferences for types as well.


3 responses to “How to deal with line feeds in Jazz RTC SCM

  1. Pingback: How to migrate source to Jazz RTC SCM « The Mac Daddy

  2. Evan Hughes (@ehues) January 30, 2013 at 10:09 pm

    Don’t forget the ‘None’ line delimiter setting.

    When a file has the ‘None’ delimiter it won’t have its line endings converted on download.

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: