A Story of Migration from SVN to Mercurial

This post inspired by a few problems with my subversion copy of fpc, fpc documentation, and lazarus when I want to compile them. All of them can be described in three, gorgeous, seemingly-important bullet-points:

  • First of all, I have them on my home directory which is fine until I want to compile. At that moment I just have to copy or export the entire tree because I’m a neat guy and it doesn’t strike me as an acceptable situation when build-generated files sprawled all over the place.
  • Second, I have set up a Mercurial repository on my private server and this thing sits on my home directory adding unnecessary burden when I have to backup stuff. Besides, when I want to have it on different computer I would like to be able to grab it from my server, not my desktop computer —which is only accessible to others when my server is powered on, a “feature” in my network topology.
  • Third, I like Mercurial (or distributed revision control in general) workflow.

I found out about hgsvn and set to try it. After a browse-reading, I think I know how to use this thingie. I ssh’d to my server and browsed to my Mercurial repository dir.


First lets start with the smallest: fpcdocs. Small enough for an import straight from the fpcdocs svn server.

me@server$ hgimportsvn -v -r 710 http://svn.freepascal.org/svn/fpcdocs/trunk fpcdocs
me@server$ cd fpcdocs
me@server$ hgpullsvn

After the minor task of creating the hgrc and modifying .hgignore file, I’m satisfied that now I can browse the fpcdocs repository from my Mercurial web-interface.

Importing From Working Copy

For the next two project (fpc and lazarus), I decided not to re-download it from the project’s subversion server because my internet connection is slow and it is unbearable to download (again) what I already have. So I decided to try to import from working copy. See --local-only on man hgimportsvn.

Since my working copy of lazarus and fpc is inside my home directory on the desktop computer I have to switch back to my desktop computer to copy it using scp. I browsed into ~/programming/pascal/followed/, a directory appropriately named to contain local copy of followed projects, before invoking the copy command.

me@desktop$ cd ~/programming/pascal/followed/
me@desktop$ scp -qr fpc lazarus me@server://tmp/

The last line is to copy directory named fpc and lazarus, located in ~/programming/pascal/followed/, to /tmp/ on the server computer. Anyway it took a while on my network, a rather slow for the impatient as myself, but then again I was streaming music :D.

For some reason scp unable to copy two MacOS-related files. This is the message:

lazarus/lazarus.app/Contents/Resources/startlazarus.app/Contents/MacOS/startlazarus: No such file or directory
lazarus/lazarus.app/Contents/MacOS/lazarus: No such file or directory

I pondered on it for a while, this looks like a symlink-gone-bad problem and I think an svn update can fix this. So I switched to my server computer, using fg:

me@desktop$ fg
me@server$ cd /tmp/lazarus/
me@server$ svn update
me@server$ cd /tmp/fpc/
me@server$ svn update

The update on lazarus and fpc reverted some file and it fixed copying related problems. Yay, everything looks okay again.

Now, to make this working copy talk and walk as a Mercurial repository I have to run hgimportsvn with --local-only option.

me@server$ cd /tmp/
me@server$ hgimportsvn --local-only /tmp/fpc/
me@server$ hgimportsvn --local-only /tmp/lazarus/

The process of transforming into a Mercurial repository took a while. After all set and done I move the two to the appropriate location, right next to fpcdocs which have been discussed earlier.

me@server$ mv fpc lazarus /media/repodisk/mercurial/FreePascal/

That command will move fpc and lazarus to where my Mercurial repositories is located; which also monitored by hgweb to provide web-interface to Mercurial repository.

After creating two hgrc file one for each repository, modifying .hgignore and doing the obligatory file-ownership changes I ran a test-drive by browsing and downloading the newly-created repositories via browser.

I can see everything is working as expected, with one minor annoyance that I can live with: no history from subversion “days”. Oh well.


Leave a comment

Filed under Orang bego punya kegiatan

Leave a Reply

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