|
ConvertingSvnToHg
Moving a project from using Subversion for code hosting to Mercurial
Convert your project from Subversion to MercurialFollow the following instructions to switch your project from Subversion to Mercurial:
Your old Subversion project will still be accessible after you switch your project to using Mercurial, so you will not need to back up your repository before switching. Your Subversion repository will remain accessible at: https://projectname.googlecode.com/svn/ How to Convert Subversion History to MercurialOption 1: Top-SkimmingIf you don't care about your project's history, then you can simply "top skim" the latest trunk code or wiki from Subversion and put it into Mercurial. Assuming your googlecode Mercurial repository is empty, it's as easy as: $ hg clone https://projectname.googlecode.com/hg hg-client $ cd hg-client $ svn export --force http://projectname.googlecode.com/svn/trunk . $ hg add . $ hg commit -m "Initial import of source." $ hg push Option 2: Full History ConversionIf want to migrate your whole history, the process is much more involved. You'll need these special tools installed first. Install tools
This already ships with recent Mercurial distributions; just make sure you're running hg version 1.1 or 1.2. ("hg --version"). Enable the extension by adding to your .hgrc: [extensions]
hgext.convert=
Make sure you have a recent Subversion installed (1.5 or 1.6). Many distributions of Subversion ship with the python bindings, or offer "extra" binary packages of them. You can check that your svn-python bindings are installed correctly by running: $ python -c "import svn.core; print svn.core.SVN_VER_MINOR"
5If this fails, or if you get a minor version less than 5, then something is wrong. If you have no binary package available and are desperate, you can build them from Subversion's own source tree: $ svn checkout http://svn.collab.net/repos/svn/tags/1.6.0 svn
$ cd svn
$ ./autogen.sh && ./configure
$ make
$ sudo make install
$ make swig-py # make sure you have swig 1.3 installed already
$ make check-swig-py
$ sudo make install-swig-pyIf you're on the Hardy version of Ubuntu, you can find version 1.5 of python-subversion in hardy-backports: http://packages.ubuntu.com/hardy-backports/python-subversion This may also require installing backports of the libsvn1, subversion, mercurial-common, and mercurial packages. Doing the ConversionNow we do the conversion -- branches, tags and all: $ mkdir hg-client $ hg convert http://projectname.googlecode.com/svn hg-client Once the conversion is done, you can push the new history up to your Google Code project (which presumably has an empty Mercurial repository): $ cd hg-client $ hg push https://projectname.googlecode.com/hg |
Sign in to add a comment
There is a much simpler way of migrating the content of the SVN repository using the hgsvn set of tools.
Information on where to find it and how to use it can be found at http://www.oreillynet.com/onlamp/blog/2007/08/dipping_my_toes_into_mercurial.html
I wouldn't trust the hgsvn toolset much. It's a script which shells-out to both the 'hg' and 'svn' commandline binaries... which means it's very brittle and likely to be less accurate than either 'hg convert' or the 'hgsubversion' project, which use the real low-level library APIs of both systems.
Works a treat! Took 10mins to get it working.
2 minor notes: "svn help" to check the version for subversion. "python-subversion" is the extras package on Ubuntu Jaunty 9.04
Szemere
In response to the email, "New Mercurial wiki repository for your Mercurial projects" from Google... I just tried to migrate our wiki to our hg repository, but I'm getting a "abort: HTTP Error 404: Not Found" error. I assume this is because they haven't begun the migrations yet. I will migrate when our wiki pages dissappear.
'hg convert' over http was too slow in my case, probably due to the huge changesets. using 'svnsync' to create a local mirror and then running 'hg convert' on it was much faster.
good link to do the way arvindht told: http://www.antwerkz.com/migrating-from-subversion-to-mercurial/
zq4wk0laptop:~/0penproj.s/ZQs/hg-client> python -c "import svn.core; print svn.core.SVN_VER_MINOR" 5 BUT! unknown exception encountered, details follow ... svn.core.SubversionException?: ("PROPFIND of '/svn/!svn/vcc/default': Could not read status line: Connection reset by peer (http://zqlib.googlecode.com)", 175002)
One gotcha that may affect other people. If you have the http_proxy environment variable set then the hg command obeys that. I use Squid and it was returning all sorts of errors (eg HTTP Error 501: Not Implemented and HTTP Error 504: Gateway Time-out) which from the command line look like the Google servers are broken or the instructions are wrong.
I didn't quite get step 4., but got wikis out by doing: svn checkout http://projectname.googlecode.com/svn/wiki and than copy pasting text back into new wikis.
If anyone has decent up-to-date instructions for getting the python paths setup with the Collabnet version of Hg on OS X, please post a link here...
To do a full history conversion on Windows using Cygwin see http://memoryleak.me.uk/2009/08/converting-subversion-to-mercurial-svn.html
hg convert - fail hgsubversion - success!
The process was trivial on my Gentoo setup; the warning was misleading! All the difficulty would have been from having to install software that for me was already installed.