Using mercurial with eclipse to edit actionscript files on os x

We have recently switched to use mercurial as our DVCS. We’re hosting our many repositories on bitbucket.

I love it.

When it comes to actionscript files, flash has always had odd newlines. For some reason, it has always used r as it’s newline. Mercurial, beeing a unix tool, likes it’s newlines to be n. So what better to do, than to make mercurial encode/decode the files for us.

To do that, we can simply add the following to our .hgrc file:

[encode]
*.as = perl -pe 's/r/n/g'
[decode]
*.as = perl -pe 's/r/n/g'

I don’t really know wether the decode part is necessary, but I like to keep it around (if someone should commit poison).