The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream




    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,757 other followers

Moving a Subversion/SVN including history to Mercurial/HG using TortoiseHG or HG command-line tools

Posted by jpluimers on 2014/11/17

This blog entry shows how I moved my repository from SVN at to mercurial.

I develop most of my software using Windows, so if you want to perform the steps below (except TortoiseHG) on a *nix or Mac machine, you have to do some backslash to slash replacement, and find out where the mercurial settings file is stored.

The rest is pretty much the same.

Note the aim was to do a one time conversion. If you want to use both SVN and HG at the same time, then HgSubVersion definitely worth looking at.

Step zero: enable the convert extension (once per client machine)

Mercurial/HG uses the convert extension to convert repositories in potentially different formats

Enable the convert extension using TortoiseHg

Enable the convert extension using TortoiseHg (click to enlarge)

What this does is add one line containing convert = to your %UserProfile%\mercurial.ini file in the [extensions] section, making my file look like this:

# Generated by TortoiseHg settings dialog
username =
convert =


That small change now allows you to run hg convert commands from your commandline.
It is a once per client machine step, so if you’ve already done it before, there is no need to do it again.

Step one: find out the SVN users

The easiest way to find out the SVN users is to dump the whole log, then use a text editor to scan for checkins.

After figuring out the SVN url for, I could start the conversion:

C:\Users\Developer\SVN\>svn log > %temp%\


Look for lines formatted like this:

r102134 | SND\jeroenp_cp | 2013-08-01 20:28:29 +0200 (Thu, 01 Aug 2013) | 1 line


A grep command like this will find them. A find command for this is virtually impossible (:

grep ^r\d*.*line[s]?$ %temp%\


Apart from SND\jeroenp_cp there were only two system users. Based in that I could create an –authormap author mapping file (I named it %temp%\ like this:

vstfs:///Framework/IdentityDomain/2327b42d-5241-43d6-9e2a-de5ac946f064\Project Collection Service


Step two: converting SVN to HG

Note: be prepared for a LONG wait. It is possible to speed this up by using an svnsync intermediate step as explained at | Migrating a large SVN repository to Mercurial on Windows. That basically mirrors your complete SVN repository locally using svnsync, then converts from there. There is another page describing the same process.

C:\Users\Developer\HG\\jeroenp>hg convert --authormap %temp%\


If you do not want everything in your SVN repository converted to HG, there are ways to filter as explained in Converting from SVN to Mercurial.

When you filter files, it is also a good idea to create a .hgignore file describing what files you don’t want to be in your HG repository in the future.

The above command results in a log that shows 1 change per line starting with the number of changesets to go (the log below is an excerpt, the full log is at

C:\Users\Developer\HG\\jeroenp>hg convert --authormap

initializing destination repository
svn: cannot probe remote repository, assume it could be a subversion repository. Use --source-type if you know better.
scanning source...
108 Created team project folder $/besharp via the Team Project Creation Wizard
107 first publication
106 Base folder structure
105 WordPressGenerateCategoriesHtmlConsoleApplication first draft.
104 Cleaned up code for publication at
103 Towards a category cloud
102 EmptyVisualStudioSolution, see
101 NumberVerificationTestProject: Bankrekeningnummer
100 BSN/SofiNummer and BankrekeningNummer complete.
9 Delphi: update to Delphi XE4 of TemporaryCursorDemo.dproj
8 Delphi: update to Delphi XE4 of HResultTests.dproj
7 Delphi: update to Delphi XE4 of HResultTests.dproj
6 Delphi added Library/RTL/WIN directory.
5 Reorganizing the location and name for i18n support in StringResourcesUnit.pas
4 Final location and name for i18n support in StringResourcesUnit.pas
3 Delphi: added LoadStringResource/LoadStringResourceProject.dpr demo with StringResourcesUnit.pas.
2 Delphi: updated AllDelphiNativeBeSharpNet.groupproj to Delphi XE4
1 Delphi: VCLLoggingTests application.
0 SVN: batch files to parse local svn working directories to get repository root URL  or switched directories.
writing author map file C:\Users\Developer\HG\\jeroenp\\.hg\authormap



Step three: pushing HG to BitBucket

The first step is to create an empty HG repository at BitBucket. I created min at

After that, it is very simple to put your HG repository on BitBucket. You can push both GIT and HG to empty repositoiees on BitBucket.

This was much faster: The hg convert took a couple of hours. The hg push less than a minute.

Note that is not my email address. It is part of http basic authentication.

C:\Users\Developer\HG\\jeroenp\>hg push
pushing to
searching for changes
http authorization required
realm: HTTP
user: jeroenp (fixed in .hg/hgrc)
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 109 changesets with 636 changes to 506 files


Step six: update your `hgrc` file with the BitBucket URL

One of the most important files for Mercurial/HG is the .hg\hgrc settings file.

You should at least edit the [paths] section to contain your BitBucket repository URL (the one you pushed it to, see the previous section).

You can edit it like this (let Notepad create a new file if it does not yet exist):

C:\Users\Developer\HG\\jeroenp\>notepad .hg\hgrc


And make it look like this (the jeroenp@ sets the username for http basic authentication which is secure as the protocol is https):

default =


Step five: checkout (nah, update!) and get to work

The final step is to checkout your working directory (in hg terms this is called hg update) from within the hg repository then start to work:

C:\Users\Developer\HG\\jeroenp\>hg update
460 files updated, 0 files merged, 0 files removed, 0 files unresolved



Though there was a long wait for the hg convert to complete, this went a lot smoother than I anticipated.

For bigger repositories, this is not suited, on the other hand the fast alternative (svnsync) does not work with CodePlex, and rsvndump needs patches. I might try hgsubversion in the future, but for now, the above worked.

Time will tell (:


Leave a Reply

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

You are commenting using your 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: