I wrote this script since I found myself always taking the same actions when performing SVN 2 GIT migrations for customers. It is a very simple wrapper around other tools so no real innovation to be found here, just automation.
Do not expect this script to automagically convert a SVN repository for you. Performing a conversion, especially on SVN repositories with complex histories, can be quite a lengthy process, usually involving a lot of trial-and-error and sometimes even fixing stuff in svn-all-fast-export.
Feel free to contact me if you need support in converting your own SVN repositories. I offer commercial support to companies. For open source projects I am willing to help out freely provided I have the time for it.
No license, do whatever you want with it.
- A Linux system
- Python3 (tested with Python 3.5)
- SVN (including svnsync)
- svn2git a.k.a. svn-all-fast-export (from https://github.com/svn-all-fast-export/svn2git/ at least v1.0.11 is advised)
- git
All dependencies should be installed in $PATH!
git clone https://github.com/MathyV/svn-migration.git
python3 svnmigrate.py create --authormap AUTHORMAP name source target
- Note that this will create a working directory called name in $CWD
- If you have no idea yet about the users to map just use an empty file, the process will inform you about unmapped users after upstream synchronization or you can look in the $CWD/name/users.txt
- There is a sample-authors.txt in the repository to view the file format
usage: svnmigrate.py create [-h] --authormap AUTHORMAP [--nofetch]
name source
positional arguments:
name Name of the project
source Source repository (URL)
optional arguments:
-h, --help show this help message and exit
--authormap AUTHORMAP
Username mapping file
--nofetch Do not perform the initial data fetch
A default rules file is installed in $CWD/name/ruleset.txt, it is pretty barren so you should add some rules to it. For more information see the svn2git documentation or https://techbase.kde.org/Projects/MoveToGit/UsingSvn2Git
python3 svnmigrate.py sync name
usage: svnmigrate.py sync [-h] [--nofetch] [--push] [--force] name
positional arguments:
name Migration project to operate on
optional arguments:
-h, --help show this help message and exit
--nofetch Do not fetch data from the remote SVN repository
The new git repositories are in $CWD/name/repos/. Check the contents and if happy push downstream. If you need to change some rules just remove the offending repository from the repos directory and start the sync again.
- create
- Create a working directory
- Save the configuration in a pickle
- Mirror the source repository locally
- Synchronize the local mirror with upstream (optional)
- Install a default ruleset
- sync
- Synchronize the local mirror with upstream (optional)
- Execute svn2git with options --identity-map, --rules and --add-metadata
- Repack the git repositories
Note that the configuration is saved very crudely in a pickle file, which means that it will probably won't withstand an update of this wrapper script.