Converting from Mercurial to Subversion
Asked Answered
E

3

24

Due to lack of Mercurial support in several tools, and managerial oppression it has become necessary to convert several trial Mercurial repositories to Subversion in order to conform with the company standard.

Are there any tools or suggestions for how to achieve this without a loss of revision history and the like?

Emmuela answered 14/12, 2009 at 4:55 Comment(2)
For the next wonderer who finds Mercurial strange and is pining for Subversion, you may find this link useful: Subversion Re-educationYetty
For the next wanderer who finds Mercurial repugnant, please do not "re-educate" yourself using the link above unless you believe that a vendor which sells Mercurial-based tools has an unbiased opinion. Maybe try respecting preferences and opinions about VCS vs DVCS tools. Many people have tried both -- or were forced to -- and have perfectly valid opinions about what they prefer, and why.Leonardoleoncavallo
E
29

The convert extension that ships with mercurial can use mercurial as a src and subversion as a dest.

hg convert --dest-type svn hgreponame svnreponame

Make sure to enable it in your .hgrc file.

If you want to keep using mercurial on the sly, then hgsubversion will allow you to do bidirectional sync.

Elam answered 14/12, 2009 at 5:27 Comment(9)
this fails after 2 revisions with abort: svn exited with status 256Emmuela
I've not used the svn dest stuff, but I have seen it change a lot lately on the mailing list. Make sure you're using the latest mercurial (1.4.1) and the latest swig bindings for the latest svn. Then start using some combination of --debug --traceback and maybe even strace. It may be necessary to start out with an entirely linear mercurial history, which is easily achieved with 'hg clone src -r tip'. I think I've heard that svn's repo format isn't up for storing mercurial merge revisions cleanly.Elam
Just a further note on this, abortions were occurring due to file-system shortcomings of some kind (ntfs3g). Just keep trying.Emmuela
I am having issues running this on windows. Have you managed this in a win64 environment? D:\work\horizon>hg convert --dest-type svn src horizon-svn --debug initializing svn repository 'horizon-svn' running: "svnadmin" "create" "D:\work\horizon\horizon-svn" < NUL: abort: svnadmin exited with status 1 D:\work\horizon>svnadmin --helpSymphonia
Sorry @Symphonia if it's a one time thing you're better off bringing up a linux VM and doing the conversion there. It looks like the answer below from nitwit came to that conclusion too.Elam
This worked for me when the input and output were subdirectories of the same directory. When I specified the input on a different drive it gave an error. Make sure the destination directory does not exist.Recondite
I ran a command in windows machine and it works great. However, in SVN all dates are wrong - they are times when conversion took place instead of when mercurial checkins were made. Is there a way to fix this?Protrusile
One note. You have to be in one director above the mercurial repository root to execute this command. So if you start HG Terminal (for example from TortoiseHg), you have to make cd .. first.Protrusile
2017 Update: On Windows 7 x64, using Mercurial v4.4.2 (TortoiseHg) and SVN v1.9.7, the command line as stated verbatim in Ry4an's answer worked perfectly for me, specifying the directory (not the SVN URL!) of the subversion conversion target. The exported changesets appear in the SVN repo tree root dir, not off some /projectpath/trunk node, so beware, this may not be exactly what you want. Try it out first using a test SVN repo target created specifically as a throw away test case.Leonardoleoncavallo
C
9

Ry4an's answer above does the trick exactly; some more detailed instructions for anyone (like me) who's having trouble:

  1. Do yourself a favor and don't try this on Windows. You'll have to install a very specific version of SVN, and even then certain things will fail with assorted error messages. My solution was to boot a clean AWS instance, yum-get the latest versions of mercurial and svn onto it, clone the HG repo, and run the convert there.

  2. Add this to your .hgrc file to enable the convert extension:

    [extensions]
    hgext.convert=
    
  3. Run this command:

    hg convert --dest-type svn <hg_directory> <directory_for_svn_output>
    
  4. You might get the following error:

    abort: svn exited with status 256
    

    Don't give up! Just run the same command again and it'll continue where it left off.

    If you continue to run into trouble, add --debug --traceback to the command line to get more details on what went wrong.

Carbylamine answered 9/6, 2011 at 7:29 Comment(5)
Erm, what does Windows have to do with any of that?Doody
@BillyONeal It's been too long, so I don't remember exactly, but under Windows my convert failed due to some syntax issues (I think it was due to some problem with formatting command-line parameters to svn.exe). Searching those errors on Google, you'll find you need a very specific version of SVN for it to work. After some time tinkering with it, I chose to just do it on AWS and it worked the first time around.Carbylamine
I failed to manage this on both windows and linux. On linux the error messages are mike@mike-virtual-machine ~/repos $ hg convert --dest-type svn ~/Horizon ~/HorizonToSvn initializing svn working copy 'HorizonToSvn-wc' scanning source... sorting... converting... 6655 baseline 30357 abort: svn exited with status 32512 mike@mike-virtual-machine ~/repos $Symphonia
This command worked fine on Windows with the TortoiseHg 4.6 and TortoiseSVN 1.11.1 CLI tools installed.Szymanowski
I also had good experience with Windows using TortoiseHG and TortoiseSVN, echoing PitaJ's comment above. My only gripe is that the revision history log dates are not the original dates, but are set to the time the conversion was performed. This could be improved, perhaps. Thanks to the FOSS community for this great software!Leonardoleoncavallo
O
3

Tailor should be able to do what you want.

Ocd answered 14/12, 2009 at 5:4 Comment(1)
@ChrisFreeman: Unfortunately it seems arstecnica.it is down. Debian still has the files in their package database: http.debian.net/debian/pool/main/t/tailor/…Ocd

© 2022 - 2024 — McMap. All rights reserved.