Special Offer: My C#/.NET Bootcamp Course is out now. Get 10% OFF using the code FRIENDS10.

Since summer this year I work with different devices from different locations on my projects. This is a huge benefit. There is nothing more inspiring than sitting in a bar looking over the lake and drinking a cool cola while working on the best projects.

As I was working with Subversion as my version control system which was hosted on one of my computers at home, there were several problems to manage. First, my host has had always to be accessible through the internet which means it was running a lot of time. Second, offline working was not possible.

Bitbucket

Because of the two reasons mentioned above, I was looking for a better option to work with. After Christmas I came around a friendly developer. He told me that he uses a service called Bitbucket for exactly the same purpose.

Getting the tools

There are only two tools required:

  • Subversion command line client
  • TortoiseHg

The first tool called Subversion command line client can be found on Apache’s project site. It is likely that you only have installed TortoiseSVN in order to do your daily work. If this is the case you have to install the Subversion command line client before you can start with the guide linked below. For Windows, I took Win32Svn on the bottom of the page which worked well for my purposes.

As you will see in the blog post linked below, the second one is mentioned in detail.

Migrating from Subversion to Mercurial

Because I wanted to keep the full history of my projects, also known as commit log, I was forced to find a way to achieve this. I quickly found an blog post from Alteridem Consulting, which I followed most.

Except a single command, I did the same as described in the article mentioned above. To get my author information right I used the following line, which transformed my information in a new repository called AndroidLVL2. I think this is a slightly unclear point of the original blog post linked above.

hg convert --authors authors.txt -s hg \scm\hg\AndroidLVL \scm\hg\AndroidLVL2

I think the guide describes pretty well how to migrate from SVN to Mercurial. But if you plan to use your Mercurial repository on Bitbucket, there is a long way to go which I want to explain in the next few sections.

Publish your repository

Bitbucket offers a way to import an existing Mercurial repository. But what do you fill in the required field URL? Well, you have to make your repository accessible through the web. This can be a painful thing which is why I tell you how to achieve it in just a few minutes.

First, you have to make your repository available through a web server. This is not a huge thing because TortoiseHg ships with such a thing. You just have to enable it. Just open the context menu on your repository in Windows Explorer and click on Web server.

TortoiseHg web server

Now you just have to fill in a free port and start your server by clicking on the Start button on the upper right corner of the dialog. That’s it.

Second, if you are sitting behind a router as I am, you need to configure your NAT to route port 9090 to your local machine. This way it will be accessible from the Internet. I recommend to remove this when you are done.

After this step you can import your Mercurial repository on the Bitbucket website.

Test your repository

To validate your work, I recommend that you clone the new repository from Bitbucket. After that you should be able to compare all the files. I recommend using directory comparing tools such as kdiff3 or Beyond Compare.

Conclusion

If you ever wanted to migrate your source, I think it is worth taking the time to do it. With this guide you should be able to get it work in a short period of time.

Claudio Bernasconi

I'm an enthusiastic Software Engineer with a passion for teaching .NET development on YouTube, writing articles about my journey on my blog, and making people smile.