Convert SVN to Mercurial (Script)

Below is a simple Python script that will traverse your online SVN repo and run the necessary commands to convert it to Mercurial. This is probably useless to most, but it saved me a great deal of time converting a large set of repos so I figured posting it couldn’t hurt:
{{{ lang=python
#!/usr/bin/env python

SVN_REPO = ‘’ #< Web location of SVN repos HG_PATH = r'/home/hg/data' #< Local location for newly converted HG repos # DO NOT EDIT PAST THIS LINE import subprocess import urllib2 import os import re # Extract SVN repos from web based front end svn_repos = re.findall(r'

  • .*
  • ‘,

    # Loop svn_repos and perform conversion
    for repo in svn_repos:
    hg_path = os.path.join(HG_PATH, repo)
    if not os.path.isdir(hg_path): #< Make clean HG dir if needed os.mkdir(hg_path) # Perform HG Convert command on repo and print results print subprocess.check_output(['hg', 'convert', '%s/%s' % (SVN_REPO, repo), repo]) }}} More detailed instructions for conversion of SVN to HG can be found [[|here]]







    Leave a Reply

    Your email address will not be published. Required fields are marked *