How to migrate/convert from SVN to Mercurial (hg) on windows

后端 未结 9 1445
南旧
南旧 2020-12-04 05:30

I\'m looking for a tool to migrate a couple of SVN repositories to Mercurial, with history, labels and so on.

I\'m using TortoiseHg (Windows x32), so ConvertExtensio

相关标签:
9条回答
  • 2020-12-04 05:55

    better late than never ...

    Two answers for the price of one ...

    1. If it is a public, open-source repo you could just use http://svn2github.com/add/ which took about half an hour to clone that repo to GitHib and then just pull that into Hg.

    2. The advantage of using hg convert is that is can be resumed. Converting SVN to Hg can take days. If you stop this it will resume from where it left off.

    Below is a batch file I wrote because Codeplex SVNbridge rubbish. The repo in this example did take a couple of days to fetch the whole history (I'm in Australia so the latency may have been a factor). I'd like to think it gave a TFS server somewhere a good beating.

    This batch file can be run at any time to pull updates from the SVN source if they happen to be the only ones left on earth actually still using SVN. I haven't tested it so see what happens if you do this so if I were you I'd abandon the original branch if you're going to edit the repo.

    The robocopy shamap stuff is to maintain the SVN history if you clone the Hg repo, shamap is ephemeral - check the batch file & shamap in (I'd do that on a new branch).

    the batch...

    @echo off
    mode con:cols=100 lines=800
    
    :: Change the SVN remote name here
    ::
    set remote=https://cinch.svn.codeplex.com/svn
    ::
    
    title Fetching SVN from %remote%. This could take...DAYS
    echo .
    echo Fetching SVN checkins from %remote%
    echo .
    echo Dependencies: Tortoise Hg and hg.exe in the Path would be ideal.
    echo using hg convert
    echo .
    echo First, I will make a backup of shamap in the hg repo folder.
    echo If shamap in .hg\ is newer then it will be copied to the repo.
    echo You should commit it so hg clones of this repo work with this.
    echo Commit this .BeeyATch file as well.
    echo shamap keeps track of what has been fetched from SVN.
    echo ok, that ends the educational part of this script...
    echo Now I will fetch SVN changes from
    echo %remote%
    echo ...
    echo ...(this could take quite some time)...
    echo ...DAYS...yes...DAYS
    echo ...especially if it's fecking Codeplex SVN...
    echo .
    echo If this craps out just run it again - it will resume from where it left off. 
    echo and fetch the rest...eventually
    echo .
    echo Control C to abort or any other key to start:
    echo .
    
    pause
    
    echo .
    :: http://mercurial.selenic.com/wiki/ConvertExtension <== see for details of shamap
    :: copy the shamap from the original convert into the .hg folder unless it is already there & newer
    :: don't panic if shamap is much bigger than the original - diff it to see why
    robocopy .\ .\.hg\ shamap /XO 
    robocopy .\.hg\ .\ shamap /XO 
    echo .
    
    hg convert --verbose --debug %remote% "%CD%"
    echo .
    echo .
    echo Finished fetching from %remote%
    title Finished fetching from %remote%
    echo Any  key to Exit
    echo .
    pause
    
    exit
    
    0 讨论(0)
  • 2020-12-04 05:56

    This is in the TortoiseHg FAQ:

    How can I convert a subversion repository to Mercurial?

    You must install svn-win32-1.4.6 command line tools, then add them to your path. Then you must enable the convert extension. At this point, you should be able to use the 'hg convert' command to do the conversion. Please direct problems/questions about the convert extension to the Mercurial mailing list or #mercurial on irc.freenode.net.

    So it is apparently possible -- I'm using Linux so I haven't tried myself.

    0 讨论(0)
  • 2020-12-04 05:58

    Mercurial has a built-in conversion extension for this.

    0 讨论(0)
提交回复
热议问题