From 6c0f2d98a3007e27fb235779b9af3f90a0baf652 Mon Sep 17 00:00:00 2001 From: Shin'ya Minazuki Date: Thu, 4 Dec 2025 23:01:14 +0900 Subject: [PATCH] Shin'ya M. > Initializing repository with 4 items... done --- COPYING | 22 +++++++++++++++++++++ README.md | 9 +++++++++ git2svn | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ svn2git | 20 +++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 COPYING create mode 100644 README.md create mode 100644 git2svn create mode 100644 svn2git diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..63454f2 --- /dev/null +++ b/COPYING @@ -0,0 +1,22 @@ + ________ ________ + /_ __/ / / / ____/ + / / / /_/ / __/ + / / / __ / /___ +/_/ /_/ /_/_____/ + + ____ ________________ _ _____ ____ ______ + / __ )/ ____/ ____/ __ \ | | / / | / __ \/ ____/ + / __ / __/ / __/ / /_/ /____| | /| / / /| | / /_/ / __/ + / /_/ / /___/ /___/ _, _/_____/ |/ |/ / ___ |/ _, _/ /___ +/_____/_____/_____/_/ |_| |__/|__/_/ |_/_/ |_/_____/ + + __ _________________ _______ ______ + / / / _/ ____/ ____/ | / / ___// ____/ + / / / // / / __/ / |/ /\__ \/ __/ + / /____/ // /___/ /___/ /| /___/ / /___ +/_____/___/\____/_____/_/ |_//____/_____/ + +Shin'ya Minazuki wrote this file. +As long as you retain this notice you can do whatever you want with this stuff. +If we meet some day, and you think this stuff is worth it, you can buy me a bottle of sake +in return. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ecd39e7 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# repository-conversion-scripts +Simple executable files to migrate repositories from one version control system to another. + +Those require a rather old version of [reposurgeon](http://catb.org/~esr/reposurgeon), as the latest one may not work +on some systems (such as [NetBSD](https://www.netbsd.org)). + +## Scripts +* [Git to Subversion](git2svn) (in [Perl](https://www.perl.org)) +* [Subversion to Git](svn2git) diff --git a/git2svn b/git2svn new file mode 100644 index 0000000..2d45d51 --- /dev/null +++ b/git2svn @@ -0,0 +1,58 @@ +#!/bin/sh + +clean() { + rm -rf ${1}.fi ${1}.fo ${1}.lift ${1}.map ${1}.opts +} +git_export() { + (cd ${1}-mirror ; repotool export) >${2}.git +} + +git_mirror() { + repotool mirror ${1} ${2}-mirror +} + +prepare() { + touch ${1}.opts + touch ${1}.map + touch ${1}.lift +} + +svn_import() { + reposurgeon "script ${2}.opts" \ + "read <${2}.git" \ + "authors read <${2}.map" \ + "sourcetype git" \ + "prefer git" \ + "script ${2}.lift" \ + "legacy write >${2}.fo" \ + "write >${2}.fi" + + reposurgeon "read <${2}.fi" \ + "prefer svn" \ + "rebuild ${repo_name}-svn" + +} + +print_usage() { + printf "usage: %s [export dir file] [mirror url repo_name] [migrate repo_name]\n" "$0" + printf "this program requires reposurgeon 3.41\n" + exit 1 +} + +case $1 in + export) + git_export $2 $3 + ;; + mirror) + git_mirror $2 $3 + ;; + migrate) + prepare $2 + svn_import $2 + clean $2 + ;; + *) + print_usage + ;; +esac + diff --git a/svn2git b/svn2git new file mode 100644 index 0000000..b8deb48 --- /dev/null +++ b/svn2git @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +# Convert SVN repositories to Git +# Requirements: +# - git +# - reposurgeon +# - svn +# - direct access to the subversion server +use warnings; +use strict; + +require("./svn2git.conf"); + +my $subversion_repo_path; +my $git_repo_path; +my $repo_name; + +print "Dumping the SVN repository: ($repo_name)\n"; +system("svnadmin dump $subversion_repo_path > $repo_name.dump") or die "Either svnadmin is not installed or there was a runtime error"; +print "Converting the repository into Git ($repo_name)\n"; +system("reposurgeon 'read <$repo_name.dump' 'prefer git' 'rebuild $git_repo_path'") or die "Either reposurgeon is not installed or there was a runtime error";