Migrating from Subversion to Mercurial

I recently moved the bot we use in freenode ##java from svn to hg.  Using hg's built in conversion utilities, this process isn't bad at all.  There are a number of steps to set things up, however, some of which aren't entirely as clear as they probably could be.  It would appear that hg's conversion routines don't like https-based svn repos so I wrote up a quick script to help my brother move a project of his to kenai and thought I'd share it here.  The heavy lifting in this script comes almost verbatim from hg convert page but hopefully this is a bit more accessible.

if [ -z "$1" ] then     echo "usage: $0 "     exit fi

if [ -z "`grep hgext.convert ~/.hgrc`" ] then     echo Enabling the conversion extension     echo "[extensions]" >> ~/.hgrc     echo "hgext.convert=" >> ~/.hgrc fi

URL=$1 DEST=mirror-svn HGDEST=mirror-hg

if [ -d "${DEST}" -o -d "${HGDEST}" ] then     echo "${DEST} or ${HGDEST} already exist. Please try working in another directory"     exit fi

svnadmin create ${DEST} echo '#!/bin/sh' > ${DEST}/hooks/pre-revprop-change chmod +x ${DEST}/hooks/pre-revprop-change svnsync init file://`pwd`/${DEST} ${URL} svnsync sync file://`pwd`/${DEST}

mkdir ${HGDEST} hg init ${HGDEST} hg convert file://`pwd`/${DEST} ${HGDEST}

As you can see, it's pretty straightforward.  I ended up using svnsync to get aroung the hg/https/svn problem.  It also makes the conversion much faster.  Once the script is done you can cd into mirror-hg and hg push it wherever you'd like.  There are some options you can do during the conversion like limiting which revisions get converted and mapping usernames and the like.  I've done nothing of the sort here but those shouldn't be too hard to add.  And if you're really that interested in those options then you should be fully capapable of doing that yourself.  :)

Also note, that if you don't need to use svnsync you can skip directly to the hg convert line (well, and the init right before it...) and hg will pull directly from the repository to do its conversion.

There it is.  It's not fancy or earth shattering but hopefully it'll help save you some heartburn.  As always, feedback is welcome.

I'm a big fan

I've been watching the Fan language for some time now after seeing it first mentioned on on Stephen Colebourne's blog.  Or maybe it was Cedric's.  Anyway, it caught my interest and i've been a voyeur ever since.  I'd peek into the site every few weeks or and see what was up.  Recently I decided to really give it a go.  Since I had so many other side projects languishing, what's one more, right?  Now, I'm not one to just sit down and start writing random code.  I need a goal.  A Project. I finally found one:  porting mercurial from python to fan.  Now, I know what you're probably asking.  "Are you daft?  Why would anyone want to do that?"  Well, there are a few answers to that.  Foremost, is that it gives me something concrete to write in Fan.  Other, more ancillary, reasons include not really needing platform specific builds (get rid of the C code!) and seeing how Fan stacks up speed wise to the python version.

Now, that last reason is the tricky one.  The first is easy enough to fulfill no matter how far down this road I go.  I mean, I'll be learning fan regardless of how functional this port is.  But to really compare speed, one has to have equally functional software.  I *could* just write some benchmarks blahblahblah but those are relatively boring and my python chops are a bit rusty.  Having me write python code for a benchmark wouldn't fair at all to python.  And probably just a little embarrassing for me to have that code out in the wild.

So my question now is, how far do I take this?  I like the fan language quite a bit.  I'm far from having mastered it (especially as parts of it are still under heavy development and discussion).  But so far, it's not too bad at all.  It's like a cleaned up Java 2.0.  I've found a number ways that *I* would "clean up" the current python code (I know "clean" is subjective and probably will start a flame war but that's not the point of all this).  I'm almost to the point where I'm going to start getting into some heavy lifting of hg protocols and the like.  I'm not sure have much further I really want to go down this path but so far I'm having fun.

If you're looking around for a new language to try or you've been thinking about fan, you should definitely give it a spin.  It's probably a little too early to commit an enterprise to since there's still some evolution going on.  And some IDE support would be nice.  (I do have Komodo Edit set up to parse the build output but no syntax support yet...)  It's definitely an interesting option if you have mixed deployment environments, though.