Sunday, March 2, 2008

Converting a Subversion repository to Mercurial

I was unsuccessful in my last attempts at converting from a Subversion repository to Mercurial.

Yesterday I thought I would give it another go. I setup a new local Subversion repository and imported a dump from one of my existing repositories. In that repository I have a fairly new project (let's call it foo) which has the standard Subversion layout (trunk, tags, branches), plus an extra directory named artifacts. There are no branches, 2 tags and about 27 commits.

$hg convert file:///path/to/repos/foo

Completed with no errors.

That looked promising, so it was time to try the biggest project in the same repository (let's call it bar). It has 1 branch, 13 tags and about 464 commits.

$hg convert file:///path/to/repos/bar
assuming destination bar-hg
initializing destination bar-hg repository
scanning source...
** unknown exception encountered, details follow
** report bug details to
** or
** Mercurial Distributed SCM (version 0.9.5)
Traceback (most recent call last):
File "/opt/local/bin/hg", line 14, in ?
File "/opt/local/lib/python2.4/site-packages/mercurial/", line 20, in run
File "/opt/local/lib/python2.4/site-packages/mercurial/", line 29, in dispatch
return _runcatch(u, args)
File "/opt/local/lib/python2.4/site-packages/mercurial/", line 45, in _runcatch
return _dispatch(ui, args)
File "/opt/local/lib/python2.4/site-packages/mercurial/", line 348, in _dispatch
ret = _runcommand(ui, options, cmd, d)
File "/opt/local/lib/python2.4/site-packages/mercurial/", line 401, in _runcommand
return checkargs()
File "/opt/local/lib/python2.4/site-packages/mercurial/", line 357, in checkargs
return cmdfunc()
File "/opt/local/lib/python2.4/site-packages/mercurial/", line 342, in
d = lambda: func(ui, *args, **cmdoptions)
File "/opt/local/lib/python2.4/site-packages/hgext/convert/", line 380, in convert
File "/opt/local/lib/python2.4/site-packages/hgext/convert/", line 257, in convert
parents = self.walktree(heads)
File "/opt/local/lib/python2.4/site-packages/hgext/convert/", line 97, in walktree
commit = self.cachecommit(n)
File "/opt/local/lib/python2.4/site-packages/hgext/convert/", line 204, in cachecommit
commit = self.source.getcommit(rev)
File "/opt/local/lib/python2.4/site-packages/hgext/convert/", line 245, in getcommit
self._fetch_revisions(from_revnum=revnum, to_revnum=stop)
File "/opt/local/lib/python2.4/site-packages/hgext/convert/", line 620, in _fetch_revisions
for entry in self.get_log([self.module], from_revnum, to_revnum):
File "/opt/local/lib/python2.4/site-packages/hgext/convert/", line 275, in get_log
for p in parent(stdout):
File "/opt/local/lib/python2.4/site-packages/hgext/convert/", line 262, in parent
raise SubversionException("child raised exception", entry)
libsvn._core.SubversionException: ('child raised exception', 160013)

Not so good. However, if I just try converting the trunk instead of the whole project:

$hg convert file:///path/to/repos/bar/trunk

The conversion completes with no errors.

In summary, trying to convert projects in Subversion to Mercurial has not gone smoothly. Doing a quick google search reveals a recent Mercurial trac issue that looks similar. Time to put this aside for now and switch to evaluating git.

1 comment:

Brad Clow said...

I upgraded Mercurial to version 1.0 and this problem doesn't occur now.